How to fix npm ERR! Missing script: "dev" in npm
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"
}
}- Add dev script for your framework
- Check for alternative script names
- Verify working directory
- Install required dev dependencies
{"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
- No "dev" key defined in package.json scripts section
- Project uses "start" instead of "dev" for development
- Running from wrong directory without package.json
- Development dependencies not installed (nodemon, vite, etc.)
- Script defined with different name (develop, serve, watch)
- Duplicate scripts objects in package.json
How to fix "npm ERR! Missing script: "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"
}
}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:
npm run dev --workspace=packages/frontendFrequently 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.