Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Weird npm ci behavior and unclear documentation #1539

Closed
sandratatarevicova opened this issue Jul 20, 2020 · 1 comment
Closed

[BUG] Weird npm ci behavior and unclear documentation #1539

sandratatarevicova opened this issue Jul 20, 2020 · 1 comment
Labels
Bug thing that needs fixing Release 6.x work is associated with a specific npm 6 release

Comments

@sandratatarevicova
Copy link
Contributor

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

  1. npm ci documentation does not mention its supported options.
  2. npm install --dev deprecation message is maybe wrong.
  3. --only=dev option does not work in npm ci.

Steps to Reproduce

I can create a sample repository and exact steps to reproduce the issues if it is helpful.

Expected Behavior

  1. npm ci documentation is clearer.
  2. npm install --dev deprecation message suggests an equivalent replacement.
  3. Either all npm install options work for npm ci or allnpm ci options are in its documentation.

Who

  • n/a

References

  • n/a
sandratatarevicova added a commit to sandratatarevicova/cli that referenced this issue Jul 28, 2020
sandratatarevicova added a commit to sandratatarevicova/cli that referenced this issue Jul 28, 2020
sandratatarevicova added a commit to sandratatarevicova/cli that referenced this issue Jul 28, 2020
ruyadorno pushed a commit that referenced this issue Aug 17, 2020
- also fix: add npm ci --dev deprecation message
- Related to #1539

PR-URL: #1575
Credit: @sandratatarevicova
Close: #1575
Reviewed-by: @ruyadorno
ruyadorno pushed a commit that referenced this issue Aug 17, 2020
- also fix: add npm ci --dev deprecation message
- Related to #1539

PR-URL: #1575
Credit: @sandratatarevicova
Close: #1575
Reviewed-by: @ruyadorno
ruyadorno pushed a commit that referenced this issue Aug 17, 2020
- also fix: add npm ci --dev deprecation message
- Related to #1539

PR-URL: #1575
Credit: @sandratatarevicova
Close: #1575
Reviewed-by: @ruyadorno
@darcyclarke darcyclarke added Bug thing that needs fixing Release 6.x work is associated with a specific npm 6 release labels Oct 30, 2020
@darcyclarke
Copy link
Contributor

npm v6 is no longer in active development; We will continue to push security releases to v6 at our team's discretion as-per our Support Policy.

If your bug is preproducible on v7, please re-file this issue using our new issue template.

If your issue was a feature request, please consider opening a new RRFC or RFC. If your issue was a question or other idea that was not CLI-specific, consider opening a discussion on our feedback repo

Closing: This is an automated message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Release 6.x work is associated with a specific npm 6 release
Projects
None yet
Development

No branches or pull requests

2 participants