FG
🛠️ Developer ToolsMicrosoft

npm v7 does not install linked packages dependencies

Freshalmost 4 years ago
Mar 14, 20260 views
Confidence Score76%
76%

Problem

Current Behavior: npm v7 does not install linked local packages dependencies. Expected Behavior: In npm v6 the dependencies of a local linked package are installed. This means that if `app` has `my-local-pkg` as a dependency, running `npm install` generates `app/node_modules` folder and also `my-local-pkg/node_modules` (with its dependencies). In npm v7, however, only `app/node_modules` is generated. Steps To Reproduce: I created the following repository to illustrate it. The `README.md` has the instructions on how to reproduce it. Simplified, the steps are: 1. Add the following folder structure: `./app` and `./my-local-pkg`, each with their own `package.json` 2. Include this in the `./app/package.json`: [code block] 3. Include this in the `./my-local-pkg/package.json`: [code block] 4. Go to `./app` and run `npm install`. npm version 6 produces: [code block] while npm version 7 produces: [code block] Compare the two outputs, npm v7 does not install `my-local-pkg` dependencies, there is no `./my-local-pkg/node_modules` folder generated. Environment: npm v7.1.2

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
74% confidence100% success rate3 verificationsLast verified Mar 14, 2026

Solution: npm v7 does not install linked packages dependencies

Low Risk

I'd also add that for me the expected behavior for local installs `npm install ../some-package` is to result in the same `package-lock.json` as installs from the registry with the only difference being the `"resolved"` field of local install pointing to `../some-package` instead of to the registry (and other related metadata like `"link": true`). This means that the dependencies of the locally in

74

Trust Score

3 verifications

100% success
  1. 1

    I'd also add that for me the expected behavior for local installs `npm install .

    I'd also add that for me the expected behavior for local installs `npm install ../some-package` is to result in the same `package-lock.json` as installs from the registry with the only difference being the `"resolved"` field of local install pointing to `../some-package` instead of to the registry (and other related metadata like `"link": true`).

  2. 2

    This means that the dependencies of the locally installed package should end up

    This means that the dependencies of the locally installed package should end up in the top level of `node_modules` unless there is a version conflict. I believe that v6 puts all of the local install package's dependencies in its `node_modules` and not in the top level `node_modules` (hopefully v7 will change this).

  3. 3

    Having the install behavior be consistent will make it easier to develop npm pac

    Having the install behavior be consistent will make it easier to develop npm packages by being able to install the package locally in development to test it out and know that it will act the same as installing it from the registry when it's published.

  4. 4

    For example, with Rollpkg:

    [code block]

Validation

Resolved in npm/cli GitHub issue #2339. Community reactions: 4 upvotes.

Verification Summary

Worked: 3
Partial: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

npmpackage-managernodejsenhancementrelease-8.xbugpriority-1