Skip to content

[BUG] Impossible to link more than one local module dependency one at a time. #2554

@tristanls

Description

@tristanls

Current Behavior:

Running :/moduleA $ npm link moduleB seems to attempt to install moduleA before linking moduleB. If moduleA depends on another local moduleC, linking moduleB into moduleA is impossible.

Expected Behavior:

Running :/moduleA $ npm link moduleB links moduleB into moduleA/node_modules/moduleB. (just like npm@6 does)

Steps To Reproduce:

Overview:

  1. Create moduleB and moduleC that are not in npm registry.
  2. Use moduleB and moduleC as a dependency in moduleA.
  3. Execute :/moduleA $ npm link moduleB. It will result in failing to find moduleC in npm registry.

Details:

$ ll
total 0
drwxr-xr-x  3 tristan  wheel   96 Jan 27 08:24 moduleA
drwxr-xr-x  3 tristan  wheel   96 Jan 27 08:23 moduleB
drwxr-xr-x  3 tristan  wheel   96 Jan 27 08:23 moduleC
$ cat moduleA/package.json 
{
  "name": "modulea",
  "version": "1.0.0",
  "dependencies": {
    "moduleb": "1.0.0",
    "modulec": "1.0.0"
  }
}
$ cat moduleB/package.json 
{
  "name": "moduleb",
  "version": "1.0.0"
}
$ cat moduleC/package.json 
{
  "name": "modulec",
  "version": "1.0.0"
}
$ cd moduleB/
:/moduleB $ npm link

up to date, audited 3 packages in 476ms

found 0 vulnerabilities
$ cd ../moduleC
:/moduleC $ npm link

up to date, audited 3 packages in 778ms

found 0 vulnerabilities

Please note that in the below step we attempt to link moduleB, but it complains about not finding moduleC.

$ cd ../moduleA
:/moduleA $ npm link moduleb
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/modulec - Not found
npm ERR! 404 
npm ERR! 404  '[email protected]' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:

For contrast, it works just fine using npm@6:

:/moduleA $ npm i -g npm@6

removed 57 packages, changed 194 packages, and audited 436 packages in 2s

3 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
:/moduleA $ npm link moduleb
/moduleA/node_modules/moduleb -> /Users/tristan/.nvm/versions/node/v15.7.0/lib/node_modules/moduleb -> /moduleB
:/moduleA $ npm link modulec
/moduleA/node_modules/modulec -> /Users/tristan/.nvm/versions/node/v15.7.0/lib/node_modules/modulec -> /moduleC

Environment:

MacOS
npm@7

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingPriority 1high priority issueRelease 7.xwork is associated with a specific npm 7 release

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions