cli icon indicating copy to clipboard operation
cli copied to clipboard

[BUG] `npm install` ignores `--production=false` (7.7.0)

Open Audio opened this issue 5 years ago • 6 comments

Current Behavior:

NODE_ENV=production npm install --production=false doesn't install project's devDependecies.

Expected Behavior:

NODE_ENV=production npm install --production=false installs devDependencies according to docs:

To install all modules listed in both dependencies and devDependencies when NODE_ENV environment variable is set to production, you can use --production=false.

Steps To Reproduce:

  1. NODE_ENV=production npm install --production=false
  2. dev dependencies are missing (npm ls prints UNMET DEPENDENCY for them)

Environment:

  • OS: MacOS BigSur 11.2.1
  • Node: 14.15.1
  • npm: 7.7.0

Audio avatar Mar 24 '21 12:03 Audio

We had this problem on Heroku today.

I think that the change is for the better, NODE_ENV=production should not install devDependencies.

Our quick-fix is to force installation of devDependencies on heroku via "heroku-postbuild": "npm install --include=dev && make prod" in package.json.

This is a change from 7.6.x and should probably not have been released before 8.0, since it broke our deployment flow half a day, meaning no updates to our website.

dotnetCarpenter avatar Mar 24 '21 13:03 dotnetCarpenter

This should be fixed in v7.7.2

wraithgar avatar Mar 24 '21 17:03 wraithgar

Thank you, but I'm still able to reproduce the issue with 7.7.2 and 7.7.3.

Audio avatar Mar 24 '21 18:03 Audio

Yep sorry about that. New PR is up and should fix it, and I screenshotted this exact scenario to show it really does fix it this time.

wraithgar avatar Mar 24 '21 20:03 wraithgar

In the short interim before this fix goes out I'd like to point out to folks that --production is deprecated, in favor of passing explicit --include and --omit values. (This was very recently deprecated, this is likely the first you're hearing about it).

So if you wanted to override NODE_ENV=production in a non-deprecated way you would use --include=dev.

wraithgar avatar Mar 24 '21 21:03 wraithgar

landed in [email protected] 🙏 please let us know if you still have any problems.

ruyadorno avatar Mar 24 '21 21:03 ruyadorno