Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

npm prints 'config production' or 'config only' and tells you to use --omit=dev

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

  • Applies to npm 10, npm 11, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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"
  2. 2Match what you see, then jump to its fix

    1. 1The warning appears only when one particular command runsA --production flag in a script, Dockerfile or CI stepFix
    2. 2The warning appears on every npm command, on any npm commandproduction=true is set in an .npmrc fileFix
    3. 3The warning names only or also instead of productionThe old only= or also=dev options are usedFix

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/null

2Fix

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=dev

3Verify

Run the command again; the warning is gone and no dev packages are installed.

npm ci --omit=dev && ls node_modules/.bin | head

Confirmed by docs.npmjs.com

Did this fix it?

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 production

2Fix

Remove the old key and set the replacement, which is the omit list.

# .npmrc
omit=dev

3Verify

npm now prints nothing extra, and the effective omit list is dev.

npm config get omit

Confirmed by docs.npmjs.com

Did this fix it?

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/null

2Fix

Use --omit=dev to leave dev packages out, or --include=dev to force them in.

npm install --omit=dev
npm install --include=dev

3Verify

Run the command once more and read the output.

npm install --omit=dev

Confirmed by docs.npmjs.com

Did this fix it?

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 fix

Back 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 fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.