npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

"npm install package@version" unexpectedly installs all dev packages

What I Wanted to Do


I want to install just one of my dev dependencies, e.g.:
npm install --no-save @angular/compiler-cli@7.2.5

What Happened Instead

The specified package is installed along with all of my dev dependencies. I didn’t expect the other dev dependencies to be installed.

Reproduction Steps

npm ci --production
npm install --no-save @angular/compiler-cli@7.2.5
npm list --depth=0

Note that other dev dependencies have been installed.

Also tested on other NPM versions using npx, with the same results:

npm ci --production
npx --ignore-existing npm@6.8.0 install --no-save @angular/compiler-cli@7.2.5
npm list --depth=0
npm ci --production
npx --ignore-existing npm@6.9.0 install --no-save @angular/compiler-cli@7.2.5
npm list --depth=0


If I add the --no-package-lock flag, and specify exactly the desired version, then I get the expected behavior, e.g.:
npm install --no-save --no-package-lock @angular/compiler-cli@7.2.5

Platform Info

$ npm --versions
{ ___redacted___: '0.0.0',
  npm: '6.4.1',
  ares: '1.14.0',
  cldr: '33.1',
  http_parser: '2.8.0',
  icu: '62.1',
  modules: '64',
  napi: '3',
  nghttp2: '1.34.0',
  node: '10.13.0',
  openssl: '1.1.0i',
  tz: '2018e',
  unicode: '11.0',
  uv: '1.23.2',
  v8: '',
  zlib: '1.2.11' }

$ node -p process.platform

(Nice use of npx in reproduction steps. :slight_smile: )

Might be related to

I was wondering if this was intentional… It’s not really what I was expecting, or desired, but admittedly, my situation is probably a corner case.