Fix Guide

npm error Missing script: "dev": How to Fix It (Also start and build)

RS
Raiyan Shahid Building ExamAI, FileForge, CodeCompiler & Party Rush under BrynFlow · Get in touch

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:

How to fix npm error Missing script: "dev"

Work through these in order and rerun your command after each one.

  1. 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:
    ls 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 dev
    If you just ran npm create vite@latest or npx create-next-app@latest my-app, the new project is in a subfolder. The tools print a cd command for exactly this reason.
  2. List the scripts with npm run. Run npm run with 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 start
    npm start is special: if there is no start script, npm runs node server.js. If that file does not exist, you see Missing script: "start" instead.
  3. Check the script name spelling. The name must match the key in "scripts" exactly. dev, Dev and develop are three different scripts. Copy the name from the npm run list rather than from the tutorial.
  4. Run the script in the right workspace. In an npm workspaces monorepo, the root package.json often has no dev script. 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
  5. Add the missing script to package.json. If the project really has no dev script, add the command your framework uses. npm pkg set edits package.json for you without breaking the JSON:
    npm 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 result
    Only add a script for a tool the project actually uses. If a tutorial says npm run dev but your project was made with a different tool, follow that tool's own start command instead.
  6. Use --if-present for optional scripts in CI. If a pipeline runs a script that only some packages define, npm's --if-present flag 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

Last checked November 30, 2026 with npm 10.9 and npm 11.

Where to go next

Dev server running? Build something real

The free Full-Stack Development track takes you from npm scripts to a deployed app step by step.

Start the Full-Stack Track