13

Every time I run any kind of npm command, I get the following error before the actual output:

npm WARN config production Use `--omit=dev` instead.

Of course I've come across similar issues regarding the -g flag, and I updated npm to avoid that problem. Some of the workarounds describe editing the npm and npm.cmd in the program files for node to remove these flags, but for this error in particular, the word production occurs nowhere in those configuration files. Unhelpfully, npm's warnings don't include a reference to the file that contains this irksome configuration setting.

Can anyone offer advice on where to search for this configuration, or at least how to silence this redundant warning message?

5 Answers5

6

And of course, as soon as I ask, I find an answer somewhere else:

I created an error log because of a different npm crash, and when I search the log, I found the config file that was causing the error:

C:\Users\Chris\AppData\Roaming\npm\etc\npmrc

Sure enough, I open the file, find production=false, delete the necessary line, and now the error has disappeared.

  • 2
    Where the hell do you find this, This is not in my react project?? please help – Mystery Man Aug 25 '22 at 18:10
  • 2
    @MysteryMan It's not in your project, it's in the npm AppData folder. Take the file path I posted and adjust it for your system (replacing 'Chris' with your user name), and you should find an `npmrc` file there that you can edit. – Christopher Walters Jan 03 '23 at 21:00
3

You can try to install production by npm --production and install --omit=dev by npm --omit=dev or check you version properly then run a command.

Tyler2P
  • 2,324
  • 26
  • 22
  • 31
Ajay Patel
  • 31
  • 2
2

This can also be triggered in CI if something sets the env var NPM_CONFIG_PRODUCTION=false. Applicable for Heroku, buildpacks, Railway and others.

Seems to be an NPM feature per https://github.com/npm/npm/issues/14168:

Setting NPM_CONFIG_PRODUCTION=true during install overrides NODE_ENV always and forever, no matter what I do. Even NODE_ENV=development npm start results in my NODE_ENV being reset to production.

[Reply] This seems to work as intended according to docs.

Grey Vugrin
  • 455
  • 5
  • 12
0

I removed the line production=false at the address below and the warning didn't appear anymore.

C:\Users\[username]\.npmrc
0

c:\Users\Am.npmrc My file only contains:

legacy-peer-deps=true
npm=install
apollo-boost=react-apollo
graphql=
stmb
  • 11
  • 2