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 ERR! code E401 npm ERR! 401 Unauthorized - Token has expired
Token has expired - npm authentication failure
npm ERR! code ENOAUDIT npm ERR! Audit endpoint not supported
How to fix "npm ERR! code ENOAUDIT - Audit endpoint not supported"
npm ERR! code EBADDEVENGINES npm ERR! devEngines.runtime incompatible with current node version
How to fix "npm ERR! code EBADDEVENGINES - devEngines.runtime incompatible with current node version"
npm ERR! code EAI_NODATA npm ERR! errno EAI_NODATA npm ERR! getaddrinfo EAI_NODATA registry.npmjs.org
How to fix "npm ERR! code EAI_NODATA - getaddrinfo EAI_NODATA"
npm ERR! code ETOOMANYARGS npm ERR! Too many arguments
How to fix "npm ERR! code ETOOMANYARGS - Too many arguments"