fix(ls): use virtual tree instead of actual for listing #3404
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It seems that
npm listis currently using the actual tree, which requiresnode_modulesto exist - this in turn means you have to be able to do a successfulnpm install(i.e meeting all requirements such as node version, OS, C libs, etc) which greatly increases the cost of any tooling that involvesnpm list.This requirement was not present in npm v6.actually it was.Additionally this means that
npm listwill include dependencies that are in the lock but not on disk due to them not meeting requirements for install (i.e optional OS-specific dependencies likefsevents). This would match the tree I'm guessingnpm auditchecks against, as currently for one of our projectsnpm auditflagsnode_modules/fsevents/node_modules/ini, but doingnpm list inidoes not show any version ofiniwithin the vulnerable range; with this change it does show up.However, this could be the complete opposite of what
npm listis meant to do, so some discussion might be needed 😓References
Resolves #3068