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

npmBEGINNERLOWUpdated Dec 6, 2025· 291 views

The "Missing script: build" error occurs when running npm run build but no build script is defined in package.json. Add the appropriate build command for your framework to resolve this.

Quick fix

Fixes npm ERR! Missing script: "build"

{
  "scripts": {
    "build": "react-scripts build"
  }
}
  1. Add build script for your framework
  2. Check available scripts
  3. Verify working directory
  4. Update deployment platform settings
npm — error
{
"scripts": {
"build": "react-scripts build"
}
}
npm ERR! Missing script: "build"

What this error means

This error indicates that npm cannot find a "build" script in your package.json file. Unlike `npm test` or `npm start`, `npm run build` is not a built-in npm command—it requires an explicit script definition. This commonly occurs when deploying to platforms like Netlify, Vercel, or Heroku that expect a build script, or when following tutorials that assume a build script exists. Not all projects need a build step—simple Node.js servers serving raw JavaScript don't require compilation.

Typical symptoms

  • npm run build fails with "Missing script: build"
  • Deployment to Netlify/Vercel/Heroku fails at build step
  • CI/CD pipeline fails during build stage
  • Following tutorial instructions that assume build script exists
  • Error lists available scripts but "build" not among them
  • Works locally but fails in production deployment

Common causes

  1. No "build" key defined in package.json scripts section
  2. Project does not require a build step (pure Node.js)
  3. Running from wrong directory that lacks package.json
  4. Script exists with different name (build:prod, build:dev)
  5. Duplicate scripts objects where second overrides first
  6. Using template/boilerplate without build configuration

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

1Add build script for your framework

Add the appropriate build script to package.json:

For React (Create React App):

json
{
  "scripts": {
    "build": "react-scripts build"
  }
}

For Vite:

json
{
  "scripts": {
    "build": "vite build"
  }
}

For Next.js:

json
{
  "scripts": {
    "build": "next build"
  }
}

For TypeScript:

json
{
  "scripts": {
    "build": "tsc"
  }
}

For Webpack:

json
{
  "scripts": {
    "build": "webpack --mode production"
  }
}
2Check available scripts

List all defined scripts to find the correct name:

bash
# Show all available scripts
npm run

# Common alternative names:
npm run build:prod
npm run build:production
npm run compile
npm run bundle
3Verify working directory

Ensure you're in the correct project directory:

bash
# Check current location
pwd

# Verify package.json exists
cat package.json | head -20

# Navigate to project root if needed
cd /path/to/project
4Update deployment platform settings

If your project doesn't need a build step, update deployment settings:

Netlify (netlify.toml):

toml
[build]
  command = "echo 'No build required'"
  publish = "public"

Or set build command in platform UI to:

bash
echo "No build step"
5Add placeholder build script

If no build is needed but something expects the script:

json
{
  "scripts": {
    "build": "echo 'No build required' && exit 0"
  }
}

This satisfies CI/CD requirements while doing nothing.

6Install missing build dependencies

If you have a build script but it fails, install dependencies:

bash
# For React
npm install react-scripts

# For Vite
npm install vite

# For TypeScript
npm install typescript

# Then try building again
npm run build

Advanced notes

Not all Node.js projects need a build step. If you're running a pure JavaScript server (Express, Fastify, etc.) without TypeScript or frontend assets, you may not need a build script at all.

For monorepos, ensure you're running the build command from the correct workspace directory, or use workspace-aware commands:

bash
npm run build --workspace=packages/my-app

Deployment platforms often let you customize the build command in their settings, which can be more flexible than modifying package.json.

Frequently asked questions

What does "npm ERR! Missing script: "build"" mean?
json file. Unlike npm test or npm start, npm run build is not a built-in npm command—it requires an explicit script definition. This commonly occurs when deploying to platforms like Netlify, Vercel, or Heroku that expect a build script, or when following tutorials that assume a build script exists.
How do I fix "npm ERR! Missing script: "build""?
The "Missing script: build" error occurs when running npm run build but no build script is defined in package.json. Add the appropriate build command for your framework to resolve this.
What causes "npm ERR! Missing script: "build""?
No "build" key defined in package.json scripts section Project does not require a build step (pure Node.js) Running from wrong directory that lacks package.json
Is the "npm ERR! Missing script: "build"" error serious?
It is a low-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading