-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Description
What / Why
I have found out that when installing dependencies using npm ci only devDependencies are installed when NODE_ENV=production environment variable is set [1]. This, unfortunately, is not mentioned in npm ci documentation, but there is this sentence:
This command is similar to npm-install, except it’s meant to be used in automated environments ...
So I have checked npm install documentation and I found this:
With the --production flag (or when the NODE_ENV environment variable is set to production), npm will not install modules listed in devDependencies.
Which probably applies for npm ci as well and explains the behavior described above. But then I dug a little deeper and found a few weird things.
--dev option [2]
Command NODE_ENV=production npm ci --dev installs both devDependencies and dependencies. This option is not mentioned in npm ci nor npm install documentation but it seems that it is deprecated, because npm install --dev prints this:
npm WARN install Usage of the `--dev` option is deprecated. Use `--only=dev` instead.
But I am not sure if --only=dev is the correct replacement for --dev option, because --only=dev installs only devDependencies and not dependencies. It seems that npm supports an --also option (unfortunately undocumented) which seems to do the same thing as --dev did, so maybe the message should be:
npm WARN install Usage of the `--dev` option is deprecated. Use `--also=dev` instead.
Note 1: npm ci does not print the deprecation message when using the --dev option.
Note 2: The --also=dev option seems to work for npm ci as well.
--only=dev option [3]
The option --only=dev works correctly with npm install, but it does not seem to work with npm ci. It always installs 0 dependencies:
npm ci --only=dev
added 0 packages in 0.079s
When
- n/a
Where
npm ci and npm install
How
Current Behavior
npm cidocumentation does not mention its supported options.npm install --devdeprecation message is maybe wrong.--only=devoption does not work innpm ci.
Steps to Reproduce
I can create a sample repository and exact steps to reproduce the issues if it is helpful.
Expected Behavior
npm cidocumentation is clearer.npm install --devdeprecation message suggests an equivalent replacement.- Either all
npm installoptions work fornpm cior allnpm cioptions are in its documentation.
Who
- n/a
References
- n/a