[BUG] `npm install -g` doesn't install local dependencies in v7
Open
Nobody has claimed this yet.
cmd:install
Documentation
Needs Discussion
Priority 2
Release 7.x
Release 8.x
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
Current Behavior:
npm install -g does not install local dependencies as part of the global install. This appears to be a breaking change between v6 and v7.
Expected Behavior:
npm install -g does install local dependencies
Steps To Reproduce:
- Create a directory containing a
package.jsonwith a dependency:
{
"name": "test",
"version": "1.0.0",
"dependencies": {
"typescript": "^4.2.3"
}
}
- In this directory, run
npm install -g.
npm v6
# npm install -g
+ test@1.0.0
added 2 packages from 1 contributor in 1.83s
# npm ls -g --depth 1
`-- test@1.0.0 -> /app
`-- typescript@4.2.3
# ls
node_modules package.json
npm v7
# npm install -g
added 1 package, and audited 3 packages in 516ms
found 0 vulnerabilities
# npm ls -g --depth 1
`-- test@1.0.0 -> /app
`-- UNMET DEPENDENCY typescript@^4.2.3
# ls
package.json
Workaround
Running a local npm install in the directory (before or after the global install) fixes the issue.
Environment:
- OS: Ubuntu 18.04
- Node: 15.12.0
- npm: 7.7.5
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
Reproduce the behavior from the issue using the shown package.json, npm install -g, and npm ls -g --depth 1 commands, comparing npm v6 and v7 if available. The fix is complete when a global install also installs the local typescript dependency and npm ls no longer reports it as unmet.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100