npm / npm/cli

[BUG] `npm link` does not work correctly with workspaces and `install-strategy=nested`

Open
#7,315 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Priority 2
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

Is there an existing issue for this?
  • I have searched the existing issues
This issue exists in the latest npm version
  • I am using the latest npm
Current Behavior

I have two projects

Puppeteer uses this .npmrc
install-strategy=nested. packages/puppeteer-core has the chromium-bidi as a dependency.

The linked package get linked at the top level rather then on the package-level.
That mean the downloaded version is always resolved by Node.

Expected Behavior

The linked packages is placed in the correct place packages/puppeteer-core/ and runs the locally linked version.

Steps To Reproduce
  1. Download puppeteer and chromium-bidi
  2. Install dependecies in both
  3. Run npm run build in both (will build anything necessary, also prevent's an issue related to linking and peerDependencies where there are type errors)
  4. Run npm link in chromium-bidi
  5. Run npm link chromium-bidi or npm link chromium-bidi -w puppeteer-core in puppeteer
  6. Observe that the packages/puppeteer-core/node_modules/chromium-bidi is the downloaded version and not the symlink one.
  7. Observe that node_module/chromium-bidi is a symlink to chromium-bidi
Environment
  • npm: 10.5.0
  • Node.js: 20.10.0
  • OS Name: Linux
  • System Model Name: -
  • npm config:
; "project" config from /usr/local/google/home/nvitkov/puppeteer/.npmrc

access = "public" 
install-strategy = "nested" 

; node bin location = ~/.nvm/versions/node/v20.10.0/bin/node
; node version = v20.10.0
; npm local prefix = ~/puppeteer
; npm version = 10.5.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue using Puppeteer's .npmrc with install-strategy=nested and the linked chromium-bidi and puppeteer-core workspace. Start by running the listed build and npm link commands, then inspect packages/puppeteer-core/node_modules/chromium-bidi and the top-level node_modules entry. Done means the workspace package contains the symlink and resolves the locally linked version.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.