Quick fix: "npm error missing script dev" means the package.json npm found has no dev script. Nine times out of ten you are in the wrong folder. cd into the folder that holds the project's package.json, run npm run to list the scripts it really has, then run the one that starts your app (often npm start or npm run serve). In a monorepo, add --workspace=<package> (step 4).
Type "npm error missing script" into Google and the suggestions are "dev", "start" and "build", in that order. It is one of the most common errors for anyone following a React, Vite, Next.js or Node.js tutorial. With npm 10 and 11 the full message looks like this:
$ npm run dev
npm error Missing script: "dev"
npm error
npm error To see a list of scripts, run:
npm error npm run
Older npm versions (9 and below) print the same thing with an npm ERR! prefix. This guide explains why the error happens and walks through the fixes in order, quickest first. Every command below comes from the official npm documentation and was tested with npm 10 and 11.
Why npm says "Missing script"
When you type npm run dev, npm does not look for a file called dev. It looks for a key named "dev" inside the "scripts" object of a package.json, and runs the command stored there. A Vite project, for example, has:
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
}
So the error appears when that key is missing from the file npm picked. The usual reasons:
- Wrong folder. npm uses the closest parent folder that contains a
package.json. If you cloned a repo intomy-app/but ran the command one level up, or inside a folder of a different project, npm reads the wrong file. - The project uses another name. Create React App projects use
start, many Vue CLI projects useserve, and a plain Node server may have onlystart. - A monorepo. The
devscript lives inapps/web/package.json, not in the root file. - A typo such as
npm run deVornpm run develop. - The script was never added, for example in an empty project created with
npm init -y.
How to fix npm error Missing script: "dev"
Work through these in order and rerun your command after each one.
- Run the command in the project folder. Check that the folder contains the project's
package.json, and ask npm which folder it is using:
If you just ranls package.json # Windows: dir package.json npm prefix # prints the folder npm treats as the project root cd my-app # move into the real project folder npm run devnpm create vite@latestornpx create-next-app@latest my-app, the new project is in a subfolder. The tools print acdcommand for exactly this reason. - List the scripts with npm run. Run
npm runwith no script name and npm prints every script it found. Use whichever one starts your app:$ npm run Lifecycle scripts included in my-app@1.0.0: start react-scripts start available via `npm run-script`: build react-scripts build $ npm startnpm startis special: if there is nostartscript, npm runsnode server.js. If that file does not exist, you seeMissing script: "start"instead. - Check the script name spelling. The name must match the key in
"scripts"exactly.dev,Devanddevelopare three different scripts. Copy the name from thenpm runlist rather than from the tutorial. - Run the script in the right workspace. In an npm workspaces monorepo, the root
package.jsonoften has nodevscript. Point npm at the package that has it:npm run dev --workspace=apps/web # or the short form: -w apps/web npm run dev --prefix ./apps/web # run in another folder without cd cd apps/web && npm run dev # or simply move into it - Add the missing script to package.json. If the project really has no
devscript, add the command your framework uses.npm pkg seteditspackage.jsonfor you without breaking the JSON:
Only add a script for a tool the project actually uses. If a tutorial saysnpm install # install the project's tools first npm pkg set scripts.dev="vite" # Vite npm pkg set scripts.dev="next dev" # Next.js npm pkg get scripts # check the resultnpm run devbut your project was made with a different tool, follow that tool's own start command instead. - Use --if-present for optional scripts in CI. If a pipeline runs a script that only some packages define, npm's
--if-presentflag skips missing scripts instead of failing the job:npm run build --if-present npm run test --workspaces --if-present
If nothing works
Read the error once more. If it says npm error code ENOENT and Could not read package.json, there is no package.json in the folder or any parent, which is a different problem: you need to clone the project again or create one with npm init. If the script exists but crashes when it runs, the "Missing script" part is solved and the new error comes from the tool itself, such as Vite or Next.js. Check that tool's docs. If you run a CLI with npx and see "could not determine executable to run", use our npx executable fix guide. You can also search the npm CLI issues for your exact output.
Learning web development from scratch? The Full-Stack Development track explains how package.json, npm scripts and dev servers fit together. React Native developers can practise in our Todo app tutorial.
Frequently asked questions
What does npm error Missing script: "dev" mean?
npm found a package.json but its scripts section has no entry called dev, so npm run dev has nothing to run. Usually you are in the wrong folder or the project names its script something else.
Why does npm start work without a start script but npm run dev does not?
npm start has a built-in default: if package.json defines no start script, npm runs node server.js. If server.js does not exist either, you get Missing script: "start". Other names such as dev and build have no default.
How do I see which scripts a project has?
Run npm run with no script name. npm lists every script in the nearest package.json. npm pkg get scripts prints the same section as JSON.
Is this the same as npm ERR! missing script: dev?
Yes. npm 9 and older print the npm ERR! prefix, while npm 10 and 11 print npm error. The cause and the fixes are the same.
Should I reinstall Node.js or delete node_modules?
No. A missing script is a package.json and folder problem, not an installation problem. Reinstalling Node or deleting node_modules will not add a script that is not defined.
Sources
- npm Docs: npm run (listing scripts, --workspace, --if-present)
- npm Docs: npm start (default node server.js)
- npm Docs: npm prefix (how npm finds the project folder)
- npm Docs: npm pkg (get and set package.json fields)
- npm Docs: Workspaces
- Vite Guide: scaffolding and default scripts
- Next.js Docs: Installation and package.json scripts
Last checked November 30, 2026 with npm 10.9 and npm 11.