The command npm run build -- --prod exited with code 1 (Angular)
The command "npm run build -- --prod" exited with code 1Short answer
Exit code 1 only says the build failed; the real message is above it. For Angular the usual cause is the --prod flag, which the CLI removed in favour of --configuration production. The second is a Node.js version outside the range your Angular supports. Run the build by hand to read the message.
Fix it fast
1Find out which cause you have
Run the same build in a terminal and read the first error, not the last line. Skip the --prod flag to see whether the build itself works.
node -v npx ng build --configuration production2Match what you see, then jump to its fix
What does the error look like?
The command "npm run build -- --prod" exited with code 1
Cause 1 of 2
The --prod flag no longer exists
1Check
Find where the flag is set: in the CI or publish step, or inside package.json scripts.
grep -rn -e "--prod" package.json angular.json *.yml *.csproj 2>/dev/null2Fix
The Angular CLI project removed the deprecated --prod option from all builders and says to use --configuration production, or -c production, when the builder's default is not production. Change the script.
"scripts": {
"build": "ng build",
"build:prod": "ng build --configuration production"
}3Verify
Run the new script. It should end with the output path and exit 0.
npm run build:prod
echo $?Confirmed by github.com
Cause 2 of 2
The build machine runs a Node.js version Angular does not support
1Check
Compare node -v on the build machine with the Node.js range for your Angular major in the version table.
node -v2Fix
Install a version from the range, for example Node.js 22 for Angular 19 to 21, and make the build use it.
nvm install 22 && nvm use 223Verify
Run the build again on that machine.
npm ci && npm run buildConfirmed by angular.dev
How do I stop it coming back?
- Name the production build in package.json, so no tool has to pass flags with a double dash.
- Pin the Node.js version in CI to the same major as your laptop.
- Use npm ci in build steps so versions match the lockfile.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
ng serve says it cannot determine the project or target
Cannot determine project for command.
The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.
3 causes, each with a fixBack end
ng fails with Cannot find module @angular/cli/bin/ng
Cannot find module '@angular/cli/bin/ng'
The ng command is the entry point to the Angular CLI package.
2 causes, each with a fixBack end
Angular app shows 'Cannot GET /' when served by a Node.js server
Cannot GET /dashboard
Cannot GET / is Express saying no route or file matches the request.
3 causes, each with a fixBack end
ng serve cannot find the dev-server builder package
Could not find the implementation for builder @angular/build:dev-server
The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.
3 causes, each with a fixBack end
Angular build says it cannot resolve '@angular/localize/init'
Can't resolve '@angular/localize/init' in '/usr/src/app/src'
The build imports @angular/localize, and that package is not in node_modules.
2 causes, each with a fixBack end
Angular build fails with SassError: Undefined variable
SassError: Undefined variable.
Sass modules loaded with @use are scoped to the file that loads them and their variables need a namespace prefix.
4 causes, each with a fix