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

[RRFC] npm explain should work even absent a lockfile and node_modules #523

Open
ljharb opened this issue Feb 5, 2022 · 2 comments
Open

Comments

@ljharb
Copy link
Contributor

ljharb commented Feb 5, 2022

Motivation ("The Why")

For example, npm/cli#4311 (comment) - when the first (ever, or first locally on a project without a lockfile) install fails, there's no lockfile and no node_modules, and no way to know why something's attempting to be installed.

Arborist has the ability to load the ideal tree in this circumstance, so there's no technical barrier I'm aware of that prevents this command from working.

Example

Solely from a package.json, npm explain foo would work without requiring a lockfile, or reified dependencies.

How

Current Behaviour

When I run npm explain foo without a lockfile or node_modules present, i get npm ERR! No dependencies found matching foo.

Desired Behaviour

I'd expect to get the same result as when either are present - the actual explanation of where foo comes from.

(If this seems like something simple enough to not require an RFC, i'd be happy to make a PR to add it)

@ljharb
Copy link
Contributor Author

ljharb commented Feb 9, 2022

Per discussion, one possible pitfall might be that the ideal tree in arborist may fail to account for bundled deps.

@ruyadorno
Copy link
Contributor

Also let's fix the support to package-lock-only, e.g: npm explain foo --package-lock-only - since that should be feasible using Arborist.loadVirtual - that can probably just be an issue open in the cli repo.

A proposed enhancement is to use loadVirtual by default in case a lock file is available but then WARN that displayed results might differ from a final reified tree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants