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] npm ls --all does not list dependency tree without node_modules #3068

Open
davidacmoreira-cx opened this issue Apr 13, 2021 · 3 comments · Fixed by #3408
Open

[BUG] npm ls --all does not list dependency tree without node_modules #3068

davidacmoreira-cx opened this issue Apr 13, 2021 · 3 comments · Fixed by #3408
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 7.x work is associated with a specific npm 7 release

Comments

@davidacmoreira-cx
Copy link

Current Behavior:

The command npm ls --all does not list the dependency tree, without node_modules folder. This command is failing to list the dependency tree with only the package-lock.json file, using npm v7.

Expected Behavior:

Using npm v6, the npm ls command is working as expected, by listing the dependency tree, with only the package.json and package-lock.json files present, and without node_modules folder.

Steps To Reproduce:

  1. In a project folder with package.json and with package-lock.json files, and without node_modules folder
  2. Run npm ls --all --json

or

  1. In a project folder with package.json
  2. Run npm install
  3. Delete de node_modules folder
  4. Run npm ls --all --json

Environment:

  • OS: Windows 10
  • Node: 14.15.1
  • npm: 7.9.0

or

  • OS: Debian 10
  • Node: 12.13.0
  • npm: 7.9.0
@davidacmoreira-cx davidacmoreira-cx added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Apr 13, 2021
@nlf
Copy link
Contributor

nlf commented Apr 13, 2021

confirmed, easy to reproduce this one. thanks for letting us know!

@nlf nlf added Priority 2 secondary priority issue and removed Needs Triage needs review for next steps labels Apr 13, 2021
@isaacs
Copy link
Contributor

isaacs commented Jun 11, 2021

Umm.... I'm pretty sure npm@6 used the actual tree as well?

Screen Shot 2021-06-11 at 14 55 50

The output is almost identical between v6 and v7. There is a problem that we print two JSON blobs when there's errors in v7, though, that's a bug.

@G-Rath
Copy link
Contributor

G-Rath commented Jun 11, 2021

Pulling my comment over from my PR, since this is the better place to discuss:

@isaacs I've got need to have npm list behaviour on the virtual tree for audit-app to backfill information on dependency paths & versions because the new auditing output doesn't have all the information we need for that - using the virtual tree means you don't have to actually be able to successfully install saving a lot of time and pain when using tooling to do mass project auditing.

Additionally, there is the sort-of bug/inconsistency with the output of npm audit vs npm list that I mentioned in my PR (I tried to make a simple reproduction, but it proved too hard to pin down to just a few dependencies since npm would keep trying to pull in patched versions of ini) that this would help explain.

Would implementing a new flag (i.e --virtual) be on the table? I'd expect from what I was when exploring this issue originally, it shouldn't be too hard to implement (just a matter of having the flag and then changing the line from my PR to be if: loadVirtual; else: loadActual.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 7.x work is associated with a specific npm 7 release
Projects
None yet
4 participants