Fix: npm ERR! Missing script: "start"
The Error
You run npm start and get:
npm ERR! Missing script: "start"
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR! npm run
npm ERR! A complete log of this run can be found in: ...The same error shows up with other script names:
npm ERR! Missing script: "dev"npm ERR! Missing script: "build"npm ERR! Missing script: "test"A related error you might see after fixing the script definition:
sh: react-scripts: command not foundAll of these mean the same thing: npm can’t find or can’t execute the script you’re trying to run.
Why This Happens
npm scripts are defined in the scripts object of your package.json. When you run npm start, npm looks for a "start" key in that object. If it’s not there, you get this error.
The most common reasons:
- The script doesn’t exist in
package.json. You cloned a repo or followed a tutorial that assumes a script is defined, but yourpackage.jsondoesn’t have it. - You’re in the wrong directory. You ran
npm startin a parent folder or subfolder that has its ownpackage.json(or none at all) instead of the project root. - You used the wrong command. Some frameworks use
npm run devinstead ofnpm start, ornpm run buildinstead ofnpm build. The difference matters. - Dependencies aren’t installed. The script exists but references a binary (like
react-scriptsorvite) that isn’t innode_modulesbecause you haven’t runnpm install.
Fix 1: Add the Missing Script to package.json
Open your package.json and add the script you need under the "scripts" object.
Here are the correct scripts for the most common setups:
React (Create React App):
{
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test"
}
}Next.js:
{
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
}
}Note: In Next.js, npm run dev starts the development server. npm start runs the production server (requires npm run build first).
Vite (React, Vue, Svelte):
{
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
}
}Angular:
{
"scripts": {
"start": "ng serve",
"build": "ng build",
"test": "ng test"
}
}Express / plain Node.js:
{
"scripts": {
"start": "node server.js",
"dev": "node --watch server.js"
}
}Replace server.js with your entry file (index.js, app.js, etc.). The --watch flag (Node.js 18.11+) restarts the server on file changes. If Node.js can’t find your entry file, see Fix: Error Cannot find module. For older Node.js versions, use nodemon:
{
"scripts": {
"start": "node server.js",
"dev": "nodemon server.js"
}
}Nest.js:
{
"scripts": {
"start": "nest start",
"start:dev": "nest start --watch",
"build": "nest build",
"test": "jest"
}
}Fix 2: Check You’re in the Right Directory
This is more common than you’d think. If your project structure looks like this:
my-project/
├── package.json ← this one might be empty or a monorepo root
├── frontend/
│ └── package.json ← the scripts are here
└── backend/
└── package.jsonRunning npm start from my-project/ will use the root package.json, which probably doesn’t have the script you want.
Navigate to the correct directory first:
cd frontend
npm startVerify you’re in the right place by checking which package.json npm sees:
cat package.json | head -20You should see the project name and the scripts you expect.
Fix 3: Install Dependencies First
If your package.json has the script defined but you get an error like:
sh: react-scripts: command not foundsh: vite: command not foundsh: next: command not foundThe script exists, but the binary it references isn’t installed. Run:
npm installThis installs all dependencies listed in package.json and puts their CLI binaries in node_modules/.bin/. When npm runs a script, it adds node_modules/.bin to the system PATH, so commands like react-scripts, vite, and next work without a global install.
If npm install itself fails, you may have a separate dependency issue — see Fix: npm ERR! ERESOLVE unable to resolve dependency tree.
Fix 4: Use the Correct Script Name
npm has a few built-in shortcuts, but most script names require npm run as a prefix. This is a common source of confusion.
Scripts that work without run:
npm start # runs the "start" script
npm test # runs the "test" scriptScripts that require run:
npm run dev # runs the "dev" script
npm run build # runs the "build" script
npm run lint # runs the "lint" scriptA common mistake is running npm dev or npm build instead of npm run dev or npm run build. Without run, npm treats these as built-in npm commands (which do something completely different), not your custom scripts.
To see all available scripts in your project:
npm runThis lists every script defined in your package.json along with its command.
Common Framework Scripts Reference
| Framework | Dev Server | Production Build | Start (Production) | Test |
|---|---|---|---|---|
| Create React App | npm start | npm run build | Serve build/ dir | npm test |
| Next.js | npm run dev | npm run build | npm start | npm test |
| Vite | npm run dev | npm run build | npm run preview | npm test |
| Angular CLI | npm start | npm run build | Serve dist/ dir | npm test |
| Express | npm run dev | N/A | npm start | npm test |
| Nest.js | npm run start:dev | npm run build | npm start | npm test |
Note: “Serve build/ dir” and “Serve dist/ dir” mean the framework produces static files. You serve them with a static file server (e.g., npx serve build) or deploy them to a hosting provider. There’s no built-in npm start for production in those cases.
Still Not Working?
node_modules/.bin is missing the binary
Even after npm install, the binary might be missing from node_modules/.bin/. This can happen if the install was interrupted or the package’s bin field is misconfigured.
Delete node_modules and reinstall:
rm -rf node_modules package-lock.json
npm installOn Windows (Command Prompt):
rmdir /s /q node_modules
del package-lock.json
npm installUse npx as an alternative
If you need to run a command once without adding it to your scripts, use npx:
npx vite
npx next dev
npx react-scripts startnpx looks in node_modules/.bin first, then downloads the package temporarily if it’s not found. This is useful for quick testing or when you don’t want to modify package.json.
Check package.json for syntax errors
A malformed package.json can cause npm to silently ignore your scripts. Validate it:
npm pkg get scriptsIf this returns {} but you know you added scripts, your package.json has a syntax error. Common mistakes:
- Trailing comma after the last entry in an object
- Missing quotes around keys or values
- Missing comma between entries
Run npx jsonlint package.json or paste it into a JSON validator to find the exact problem.
Monorepo: you’re in the wrong workspace
In monorepo setups with npm workspaces, Yarn workspaces, or pnpm workspaces, each workspace has its own package.json with its own scripts. Running npm start from the root won’t run a workspace’s script unless you specify it:
npm start --workspace=packages/frontendOr navigate into the workspace directory:
cd packages/frontend
npm startIf you’re using Turborepo or Nx, use their CLI instead:
npx turbo run dev
npx nx serve my-apppackage.json has no scripts object at all
If you initialized a project with npm init -y and never added scripts, your package.json only has the default "test" script (which just prints an error). Make sure your environment variables are also configured before running your app. Add the scripts object manually or re-scaffold with your framework’s CLI:
npx create-react-app my-app
npx create-next-app my-app
npm create vite@latest my-appRelated: If npm install fails with dependency conflicts, see Fix: npm ERR! ERESOLVE unable to resolve dependency tree.
Related Articles
Fix: EACCES: permission denied, mkdir / open / unlink (Node.js)
How to fix EACCES permission denied errors in Node.js for mkdir, open, unlink, and scandir operations, covering npm global installs, Docker, NVM, CI/CD, and filesystem permissions.
Fix: npm ERR! code ELIFECYCLE (errno 1, Failed at script)
How to fix npm ERR! code ELIFECYCLE, npm ERR! errno 1, and npm ERR! Failed at the script errors. Covers reading the real error, node_modules corruption, node-gyp failures, wrong Node version, memory issues, postinstall failures, Windows-specific fixes, and more.
Fix: npm ERR! ERESOLVE unable to resolve dependency tree
How to fix the ERESOLVE unable to resolve dependency tree error in npm. Covers root causes, peer dependency conflicts, --legacy-peer-deps, --force, npm overrides, and edge cases with React 18, TypeScript, and monorepos.
Fix: EACCES permission denied when installing npm packages globally
How to fix 'Error: EACCES: permission denied, access /usr/local/lib/node_modules' when running npm install -g on macOS or Linux. Multiple solutions ranked by recommendation.