cli icon indicating copy to clipboard operation
cli copied to clipboard

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

Open Lightning00Blade opened this issue 1 year ago • 0 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

This issue exists in the latest npm version

  • [X] I am using the latest npm

Current Behavior

I have two projects

  • https://github.com/puppeteer/puppeteer
  • https://github.com/GoogleChromeLabs/chromium-bidi

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

Lightning00Blade avatar Mar 26 '24 12:03 Lightning00Blade