[RRFC] `npm explain` should work even absent a lockfile and node_modules
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 777
- Forks
- 267
- PR merge metrics
- No merged PRs in 30d
Description
Motivation ("The Why")
For example, https://github.com/npm/cli/issues/4311#issuecomment-1030707030 - 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)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the npm explain behavior described in the issue and Arborist's ability to load the ideal tree. Reproduce the command using only package.json, without a lockfile or node_modules, and compare it with runs where dependencies are present. Done means npm explain foo reports where foo comes from in the lockfile-free case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100