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.
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.
See what scripts are defined:
npm run
# Or view directly
cat package.json | jq .scriptsCommon typos:
# These are different!
npm run dev # vs
npm run start # vs
npm run serve
npm test # vs
npm run testNote: npm test, npm start are shortcuts.
Make sure you're in the right place:
pwd
ls package.json
# Check it's the right project
cat package.json | grep nameDefine the script:
{
"scripts": {
"start": "node index.js",
"dev": "nodemon index.js",
"build": "webpack",
"test": "jest"
}
}Run package binaries directly:
# Instead of npm run script
npx webpack
npx jest
npx eslint .Doesn't require script in package.json.
Find correct commands:
1. Read README.md
2. Check CONTRIBUTING.md
3. Look at other scripts for clues
4. Search project issues/discussions
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.
npm error code ENOENT npm error syscall spawn git npm error path git npm error errno -4058 npm error enoent An unknown git error occurred
How to fix "spawn git ENOENT" in npm
npm error code E401 npm error Incorrect or missing password.
How to fix 'E401 Unable to authenticate' errors with npm private registries
npm notice access token expired or revoked. Please try logging in again.
Token has expired - npm authentication failure
npm ERR! code EAI_AGAIN
How to fix "EAI_AGAIN" in npm
npm error code E403 npm error 403 Forbidden - PUT https://registry.npmjs.org/<package>
How to fix 'E403 Forbidden' error in npm