Skip to content
npm ERR! missing script: ...

npm ERR! missing script: ...

DodaTech 2 min read

The npm ERR! missing script error means the script is not defined in package.json. Fix it by adding it to the scripts section or checking for typos.

What It Means

npm looks up the script name in package.json under the "scripts" object. If the key doesn’t exist, npm exits with this error. It shows the exact script name you typed, so a typo is immediately visible. The error includes Did you mean this? suggestions if npm finds similar script names.

Why It Happens

  • You typed the script name wrong (e.g., npm run strat instead of npm run start).
  • The project’s package.json doesn’t define that script at all.
  • You’re in the wrong directory — you might be running the command outside the project root.
  • The project expects a different package manager (e.g., yarn dev vs npm run dev).
  • The package.json is malformed (JSON syntax error).

How to Fix It

1. Check the available scripts

npm run

This prints all available scripts defined in package.json. Compare the output with the script name you’re trying to run.

2. Check package.json directly

cat package.json | grep -A 20 '"scripts"'

Or view the full scripts section:

node -e "console.log(JSON.parse(require('fs').readFileSync('package.json','utf8')).scripts)"

3. Add the missing script

Edit package.json and add the missing script under the "scripts" field:

"scripts": {
  "dev": "vite",
  "build": "vite build",
  "start": "node server.js"
}

Then run:

npm run dev

4. Check your working directory

pwd
ls package.json

If package.json doesn’t exist, you’re in the wrong folder or the project hasn’t been initialized. Run npm init -y to create one.

5. Restore a missing package.json

If the file was accidentally deleted, recover it from version control or recreate it:

git checkout package.json          # if using git
npm init -y                        # create a new one (lose custom scripts)
Why does npm run show no scripts at all?
If npm run shows an empty list or lifecycle scripts only, your package.json either has no "scripts" field or the field contains no entries. Run npm init -y to generate a basic package.json with a default "test" script, then add your custom scripts manually.
Is npm start different from npm run start?
npm start is an alias for npm run start — npm provides built-in aliases for start, test, stop, and restart. For any custom script (e.g., dev, build, lint), you must use npm run <script> explicitly.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro