Skip to content

[BUG] npm install -g doesn't install local dependencies in v7 #2968

Open
@mikeharder

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:

  1. Create a directory containing a package.json with a dependency:
{
  "name": "test",
  "version": "1.0.0",
  "dependencies": {
    "typescript": "^4.2.3"
  }
}
  1. 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

Metadata

Assignees

No one assigned

    Labels

    Documentationdocumentation related issueNeeds Discussionis pending a discussionPriority 2secondary priority issueRelease 7.xwork is associated with a specific npm 7 releaseRelease 8.xwork is associated with a specific npm 8 releasecmd:installrelated to `npm install`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions