How to fix npm ERR! Missing script: "dev" in npm

npmBEGINNERLOWUpdated Dec 6, 2025· 440 views

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.

Quick fix

Fixes npm ERR! Missing script: "dev"

{
  "scripts": {
    "dev": "vite"
  }
}
  1. Add dev script for your framework
  2. Check for alternative script names
  3. Verify working directory
  4. Install required dev dependencies
npm — error
{
"scripts": {
"dev": "vite"
}
}
npm ERR! Missing script: "dev"

What this error means

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").

Typical symptoms

  • npm run dev fails with "Missing script: dev"
  • Development server does not start
  • Following tutorial that uses "npm run dev"
  • Project cloned but missing expected scripts
  • Error shows available scripts but "dev" not listed
  • Works after project setup but fails on fresh clone

Common causes

  1. No "dev" key defined in package.json scripts section
  2. Project uses "start" instead of "dev" for development
  3. Running from wrong directory without package.json
  4. Development dependencies not installed (nodemon, vite, etc.)
  5. Script defined with different name (develop, serve, watch)
  6. Duplicate scripts objects in package.json

How to fix "npm ERR! Missing script: "dev""

1Add dev script for your framework

Add the appropriate dev script to package.json:

For Vite:

json
{
  "scripts": {
    "dev": "vite"
  }
}

For Next.js:

json
{
  "scripts": {
    "dev": "next dev"
  }
}

For Node.js with nodemon:

json
{
  "scripts": {
    "dev": "nodemon index.js"
  }
}

For Webpack Dev Server:

json
{
  "scripts": {
    "dev": "webpack serve --mode development"
  }
}

For Create React App (uses start instead):

json
{
  "scripts": {
    "dev": "react-scripts start"
  }
}
2Check for alternative script names

List available scripts—your project may use a different name:

bash
# Show all scripts
npm run

# Common alternatives to try:
npm start
npm run serve
npm run develop
npm run watch
3Verify working directory

Ensure you're in the project root:

bash
# Check location
pwd

# Verify package.json exists
ls package.json

# Check scripts section
cat package.json | grep -A 20 '"scripts"'
4Install required dev dependencies

The dev script may require tools that aren't installed:

bash
# Install dependencies first
npm install

# Common dev tools:
npm install --save-dev nodemon
npm install --save-dev vite
npm install --save-dev webpack-dev-server
5Use npx to run dev tools directly

As a workaround, run the development tool directly:

bash
# Vite
npx vite

# Next.js
npx next dev

# Nodemon
npx nodemon index.js

# Webpack
npx webpack serve
6Check for duplicate scripts objects

Ensure only one scripts section exists in package.json:

json
// Wrong - second scripts overrides first
{
  "scripts": { "dev": "vite" },
  "scripts": { "build": "vite build" }
}

// Correct - single scripts object
{
  "scripts": {
    "dev": "vite",
    "build": "vite build"
  }
}

Advanced notes

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:

bash
npm run dev --workspace=packages/frontend

Frequently asked questions

What does "npm ERR! Missing script: "dev"" mean?
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").
How do I fix "npm ERR! Missing script: "dev""?
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.
What causes "npm ERR! Missing script: "dev""?
No "dev" key defined in package.json scripts section Project uses "start" instead of "dev" for development Running from wrong directory without package.json
Is the "npm ERR! Missing script: "dev"" error serious?
It is a low-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading