The "Missing script: dev" error occurs when running npm run dev but no dev script is defined in package.json. Add a development server script appropriate for your framework to resolve this.
This error means npm cannot find a "dev" script in your package.json file. The `dev` script is a common convention for starting a development server with features like hot reloading, but it's not a built-in npm command—it must be explicitly defined. This typically happens when following framework documentation that assumes a dev script exists, or when cloning a project that uses different script naming conventions (like "start" instead of "dev").
Add the appropriate dev script to package.json:
For Vite:
{
"scripts": {
"dev": "vite"
}
}For Next.js:
{
"scripts": {
"dev": "next dev"
}
}For Node.js with nodemon:
{
"scripts": {
"dev": "nodemon index.js"
}
}For Webpack Dev Server:
{
"scripts": {
"dev": "webpack serve --mode development"
}
}For Create React App (uses start instead):
{
"scripts": {
"dev": "react-scripts start"
}
}List available scripts—your project may use a different name:
# Show all scripts
npm run
# Common alternatives to try:
npm start
npm run serve
npm run develop
npm run watchEnsure you're in the project root:
# Check location
pwd
# Verify package.json exists
ls package.json
# Check scripts section
cat package.json | grep -A 20 '"scripts"'The dev script may require tools that aren't installed:
# Install dependencies first
npm install
# Common dev tools:
npm install --save-dev nodemon
npm install --save-dev vite
npm install --save-dev webpack-dev-serverAs a workaround, run the development tool directly:
# Vite
npx vite
# Next.js
npx next dev
# Nodemon
npx nodemon index.js
# Webpack
npx webpack serveEnsure only one scripts section exists in package.json:
// Wrong - second scripts overrides first
{
"scripts": { "dev": "vite" },
"scripts": { "build": "vite build" }
}
// Correct - single scripts object
{
"scripts": {
"dev": "vite",
"build": "vite build"
}
}The naming convention varies by framework and community preference:
- Vite/Next.js/Nuxt: Typically use "dev"
- Create React App: Uses "start" for development
- Express/Node.js: Often uses "start" or "dev" with nodemon
When cloning repositories, always check the README or package.json for the correct development command. Some projects document this in a "Getting Started" or "Development" section.
In monorepos, you may need to run dev scripts from specific workspace directories or use workspace-aware commands:
npm run dev --workspace=packages/frontendnpm 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"