[BUG] npm install -g
doesn't install local dependencies in v7 #2968
Open
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.json
with 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