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