Installing a package with a mismatching peer dependency causes the peer dependency to disappear from npm ls

cli
help-wanted
priority:low
triaged

(Eric White) #1

Copying from: https://github.com/npm/npm/issues/21100

I’m opening this issue because:

  • npm is crashing.
    • npm is doing something I don’t understand.
  • npm is producing incorrect or undesirable behavior.
  • Other ( see below for feature requests ):
  • npm is producing an incorrect install.

What’s going wrong?

Installing a package with a mismatching peer dependency causes the peer dependency to disappear from npm ls. The package still exists in node_modules and the binary in node_modules/.bin.

How can the CLI team reproduce the problem?

➜ Projects mkdir jest-test
➜ Projects cd jest-test
➜ jest-test npm init
yes to all…
➜ jest-test npm i -D jest
➜ jest-test npm ls jest
jest-test@1.0.0 /Users/ville.lahdenvuo/Projects/jest-test
└── jest@23.2.0
all good so far…
➜ jest-test npm i -D jest-preset-angular
npm WARN jest-preset-angular@5.2.3 requires a peer of @angular/core@>=2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN jest-preset-angular@5.2.3 requires a peer of @angular/platform-browser-dynamic@>=2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN jest-preset-angular@5.2.3 requires a peer of jest@^22.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN jest-zone-patch@0.0.8 requires a peer of zone.js@>=0.7.5 but none is installed. You must install peer dependencies yourself.
npm WARN ts-jest@22.4.6 requires a peer of typescript@2.x but none is installed. You must install peer dependencies yourself.

  • jest-preset-angular@5.2.3
    added 81 packages from 138 contributors and audited 60602 packages in 7.509s
    found 0 vulnerabilities

➜ jest-test npm ls jest
jest-test@1.0.0 /Users/ville.lahdenvuo/Projects/jest-test
└── (empty)
what? the dependency is gone because it doesn’t match the peer dependency???

This is very confusing to me, is it by design?

supporting information:

  • npm -v prints: 6.1.0
  • node -v prints: v10.3.0
  • npm config get registry prints: https://registry.npmjs.org/
  • Windows, OS X/macOS, or Linux?: macOS
  • Network issues:
    • Geographic location where npm was run:
    • I use a proxy to connect to the npm registry.
    • I use a proxy to connect to the web.
    • I use a proxy when downloading Git repos.
    • I access the npm registry via a VPN
    • I don’t use a proxy, but have limited or unreliable internet access.
  • Container:
    • I develop using Vagrant on Windows.
    • I develop using Vagrant on OS X or Linux.
    • I develop / deploy using Docker.
    • I deploy to a PaaS (Triton, Heroku).

Failed to install eslint in a specific situation