How to fix npm ERR! Missing script: in npm

npmBEGINNERLOWUpdated Dec 6, 2025ยท 314 views

The "missing script" error occurs when you try to run an npm script that doesn't exist in package.json. Check your script name spelling or add the missing script to package.json.

Quick fix

Fixes npm ERR! Missing script:

npm run

# Or view directly
cat package.json | jq .scripts
  1. List available scripts
  2. Check script name spelling
  3. Verify correct directory
  4. Add the missing script
npm โ€” error
npm run
# Or view directly
cat package.json | jq .scripts
npm ERR! Missing script:

What this error means

npm run <script> looks for the script in your package.json's "scripts" object. If the script name isn't found, npm reports this error. This often happens with typos, when running commands from tutorials that assume certain scripts exist, or when switching between projects with different script configurations.

Typical symptoms

  • npm run command fails with "missing script"
  • Script name misspelled
  • Copied command from tutorial
  • Script exists in different project
  • Script was renamed or removed
  • Wrong directory

Common causes

  1. Typo in script name
  2. Script not defined in package.json
  3. Running in wrong directory
  4. Script removed or renamed
  5. Using wrong project's commands
  6. Tutorial assumes script exists

How to fix "npm ERR! Missing script:"

1List available scripts

See what scripts are defined:

bash
npm run

# Or view directly
cat package.json | jq .scripts
2Check script name spelling

Common typos:

bash
# These are different!
npm run dev    # vs
npm run start  # vs
npm run serve

npm test    # vs
npm run test

Note: npm test, npm start are shortcuts.

3Verify correct directory

Make sure you're in the right place:

bash
pwd
ls package.json

# Check it's the right project
cat package.json | grep name
4Add the missing script

Define the script:

json
{
  "scripts": {
    "start": "node index.js",
    "dev": "nodemon index.js",
    "build": "webpack",
    "test": "jest"
  }
}
5Use npx for one-off commands

Run package binaries directly:

bash
# Instead of npm run script
npx webpack
npx jest
npx eslint .

Doesn't require script in package.json.

6Check project documentation

Find correct commands:

1. Read README.md
2. Check CONTRIBUTING.md
3. Look at other scripts for clues
4. Search project issues/discussions

Advanced notes

npm has built-in shortcuts: npm test (npm t), npm start, npm stop, npm restart. These don't require "run". Script names are case-sensitive. In monorepos, run scripts with -w flag for specific workspace. Consider using npm-run-all for running multiple scripts.

Frequently asked questions

What does "npm ERR! Missing script:" mean?
json's "scripts" object. If the script name isn't found, npm reports this error. This often happens with typos, when running commands from tutorials that assume certain scripts exist, or when switching between projects with different script configurations.
How do I fix "npm ERR! Missing script:"?
The "missing script" error occurs when you try to run an npm script that doesn't exist in package.json. Check your script name spelling or add the missing script to package.json.
What causes "npm ERR! Missing script:"?
Typo in script name Script not defined in package.json Running in wrong directory
Is the "npm ERR! Missing script:" error serious?
It is a low-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading