npm "missing script: build" in CI - Fix Undefined npm Scripts
npm run <name> looks up the script in package.json scripts. A missing-script error means there is no entry by that name in the package npm is running in.
What this error means
npm run build (or another name) fails immediately with missing script: build. The script exists in another package, or the job runs in a directory whose package.json has no such script.
npm
npm ERR! Missing script: "build"
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR! npm runCommon causes
The script is not defined in this package.json
The scripts block has no build entry, or it is named differently (build:prod).
The job runs in the wrong workspace
In a monorepo the script lives in a different package than the one the step runs in.
How to fix it
Define or correct the script name
- List available scripts to confirm the exact name.
- Add the missing script or call the correct name.
Terminal
npm run
# add to package.json scripts:
# "build": "vite build"Run in the right workspace
- Set working-directory to the package that defines the script.
- Or use a workspace filter to target it.
Terminal
npm run build --workspace=@acme/webHow to prevent it
- Keep script names consistent across packages, document them, and run npm run in CI to surface the available list when a name is wrong.
Related guides
npm "Missing script" - Fix "npm run" Cannot Find the Script in CIFix npm "Missing script: build" in CI - npm run cannot find the named script because it is absent, misspelled…
npm "Missing script" - Fix npm run for a Script That Does Not ExistFix npm "Missing script: <name>" in CI - npm run was called for a script not defined in package.json, a typo,…
npm run build Exited With Code 1 in CI - Diagnose Build FailuresDiagnose "npm run build exited with code 1" in CI by reading the real build error above the npm wrapper inste…