cli icon indicating copy to clipboard operation
cli copied to clipboard

[BUG] npm exec -w [workspace] doesn't local deps installed in parent-repository node_modules

Open wimbarelds opened this issue 10 months ago • 2 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

When a workspace has a (bin) @scope/dependency thats installed in the root-workspace's node_modules; and you execute it with npm exec -w child-workspace @scope/name, the node_modules from root-workspace is ignored and global version is used instead.

Added problem: Since the global node_modules is used, a different version of the package may be used.

Expected Behavior

npm exec -w child-workspace @scope/name uses root_workspace/node_modules/@scope/name

Steps To Reproduce

npm init -y
npm init -w child-workspace -y
npm i -w child-workspace @pega/[email protected]
npm exec -w child-workspace @pega/dx-component-builder-sdk

Result:

Need to install the following packages:
@pega/[email protected]
Ok to proceed? (y)

Environment

  • npm: 10.5.0
  • Node.js: 20.12.2
  • OS Name: MacOS Sonoma 14.3.1
  • System Model Name: Apple M1 Pro
  • npm config:
% npm config ls
; node bin location = /Users/wimbarelds/.nvm/versions/node/v20.12.2/bin/node
; node version = v20.12.2
; npm local prefix = /Users/wimbarelds/projects/npm-test
; npm version = 10.5.0
; cwd = /Users/wimbarelds/projects/npm-test
; HOME = /Users/wimbarelds
; Run `npm config ls -l` to show all defaults.

Notes:

  • I am not completely sure if the scope is relevant
    • I do not have this issue with eslint
    • I do have this issue with @pega/dx-component-builder-sdk.
  • I can confirm this issue does not occur with npm 9.8.1

wimbarelds avatar Apr 16 '24 11:04 wimbarelds

@wimbarelds try with npm exec -w child-workspace --package=@pega/dx-component-builder-sdk

milaninfy avatar Apr 24 '24 14:04 milaninfy

@wimbarelds try with npm exec -w child-workspace --package=@pega/dx-component-builder-sdk

Same result as npm exec -w child-workspace @pega/dx-component-builder-sdk, it wants to install global and not use the version already in node_modules

wimbarelds avatar Apr 30 '24 08:04 wimbarelds