npm prints 'config production' or 'config only' and tells you to use --omit=dev
npm warn config production Use `--omit=dev` instead.Short answer
npm only renamed an option. The old production and only settings still work as aliases for omit=dev, but npm warns when it sees them. Find where the old setting is set: a --production flag in a script or Dockerfile, a production=true line in .npmrc, or an environment variable. Replace it with --omit=dev.
Fix it fast
1Find out which cause you have
List every place npm reads configuration from. The line with the old key shows which file or flag supplies it.
npm config list -l | grep -E "production|only"2Match what you see, then jump to its fix
- 1
The warning appears only when one particular command runsA --production flag in a script, Dockerfile or CI stepFix - 2
The warning appears on every npm command, on any npm commandproduction=true is set in an .npmrc fileFix - 3
The warning names only or also instead of productionThe old only= or also=dev options are usedFix
- 1
What does the error look like?
npm warn config production Use `--omit=dev` instead.npm warn config only Use `--omit=dev` to omit dev dependencies from the install.
Cause 1 of 3
A --production flag in a script, Dockerfile or CI step
1Check
Search the project and the pipeline files for the flag.
grep -rnE -- "--production|--only=" package.json Dockerfile .github .gitlab-ci.yml 2>/dev/null2Fix
Swap the flag for --omit=dev. The npm config reference marks production as deprecated and calls it an alias for --omit=dev.
npm ci --omit=dev
npm install --omit=dev3Verify
Run the command again; the warning is gone and no dev packages are installed.
npm ci --omit=dev && ls node_modules/.bin | headConfirmed by docs.npmjs.com
Cause 2 of 3
production=true is set in an .npmrc file
1Check
npm reads the project .npmrc, the user .npmrc and the global one. Look for the key in each.
grep -n "production\|only" .npmrc ~/.npmrc 2>/dev/null
npm config get production2Fix
Remove the old key and set the replacement, which is the omit list.
# .npmrc
omit=dev3Verify
npm now prints nothing extra, and the effective omit list is dev.
npm config get omitConfirmed by docs.npmjs.com
Cause 3 of 3
The old only= or also=dev options are used
1Check
npm lists only (prod or production) as an alias for omit=dev, and also=dev as an alias for include=dev, both deprecated.
grep -rnE -- "--only|--also|only=|also=" package.json .npmrc Dockerfile 2>/dev/null2Fix
Use --omit=dev to leave dev packages out, or --include=dev to force them in.
npm install --omit=dev
npm install --include=dev3Verify
Run the command once more and read the output.
npm install --omit=devConfirmed by docs.npmjs.com
How do I stop it coming back?
- Use omit and include in new scripts and Dockerfiles, never production, only or also.
- Keep one place for the setting: either .npmrc or the command line, not both.
- Read warnings in CI logs after every Node or npm upgrade; renamed options start as warnings.
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
The command npm run build -- --prod exited with code 1 (Angular)
The command "npm run build -- --prod" exited with code 1
Exit code 1 only says the build failed; the real message is above it.
2 causes, each with a fix