The Missing script error occurs when you try to run an npm script that doesn't exist in your package.json. Verify the script name, check you're in the correct directory, and ensure your package.json has the required scripts section.
This error means npm couldn't find the script you're trying to run in your package.json file. When you execute `npm run dev` or `npm start`, npm looks for a matching entry in the "scripts" section of package.json. If there's no match, you get this error. The error is straightforward but can occur for several reasons: you might be in the wrong directory, the script might have a different name than expected, or the package.json might not have been properly initialized. This is one of the most common npm errors, especially for developers new to a project or when following tutorials that assume certain scripts exist.
Run npm run without any arguments to see all available scripts:
npm runThis shows the complete list of scripts defined in your package.json, helping you find the correct name.
Make sure you're in the project root where package.json is located:
ls package.jsonIf the file doesn't exist, navigate to the correct directory:
cd /path/to/your/projectOpen package.json and look for the scripts section:
{
"scripts": {
"start": "node index.js",
"dev": "vite",
"build": "vite build",
"test": "jest"
}
}If your desired script is missing, add it with the appropriate command.
Common typos include:
- npm run bulid instead of npm run build
- npm run dve instead of npm run dev
- Extra spaces in the command
Script names are case-sensitive, so npm run Dev won't find a script named dev.
If the script genuinely doesn't exist, add it to package.json:
{
"scripts": {
"dev": "next dev",
"start": "next start",
"build": "next build"
}
}The command depends on your framework (Vite, Next.js, Create React App, etc.).
If there's no package.json at all, create one:
npm init -yThen add your scripts manually or install your framework, which will set up appropriate scripts.
Different frameworks use different default script names. Create React App uses start for development, while Vite uses dev. Next.js uses dev for development and start for production. Always check the framework's documentation for expected script names.
The npm start command is special—it runs the "start" script without needing run (unlike npm run build). Similarly, npm test runs the "test" script directly.
In monorepos, you might need to run scripts from a specific workspace:
npm run dev --workspace=packages/frontendOr from the workspace directory itself. Check your monorepo configuration for the correct approach.
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"