cli icon indicating copy to clipboard operation
cli copied to clipboard

[BUG] workspaces `install-strategy = "nested"` does not install/ignores dependencies

Open samuelstroschein opened this issue 2 years ago • 3 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

npm does not install dependencies of package-b when install-strategy = "nested", and package-b is nested in another package (package-a). Not in the root of the workspace or the package itself.

- package-a
  - package-b
    package.json (dependencies of b)
  package.json (dependencies of a)
- package.json (workspaces)

Expected Behavior

Install the dependencies of package-b.

Steps To Reproduce

  1. clone https://github.com/samuelstroschein/reproduction-npm-nested-packages-bug
  2. run npm i

Environment

  • npm: v8/v9/v10 happens on every version of npm
  • Node.js: v18/v20
  • OS Name: Mac OS
  • System Model Name:
  • npm config:
; "user" config from /Users/samuel/.npmrc

access = "public" 
legacy-peer-deps = false 

; "project" config from /Users/samuel/Desktop/repro/.npmrc

install-strategy = "nested" 

; node bin location = /Users/samuel/.nvm/versions/node/v20.8.0/bin/node
; node version = v20.8.0
; npm local prefix = /Users/samuel/Desktop/repro
; npm version = 10.1.0
; cwd = /Users/samuel/Desktop/repro
; HOME = /Users/samuel
; Run `npm config ls -l` to show all defaults.

samuelstroschein avatar Oct 06 '23 15:10 samuelstroschein

maybe related https://github.com/npm/cli/issues/4774 but npm <8.5 also doesn't work

samuelstroschein avatar Oct 06 '23 15:10 samuelstroschein

I think I'm having this same issue. It seems like a standard install-strategy="nested" just doesn't work at all. Anybody know if there are any updates on this?

mryckman avatar Feb 28 '24 17:02 mryckman

npm i --install-strategy=nested pkg_name is the only way I have found that works consistently. This will result in the proper nested config in package-lock.json. Use npm i once you have the package-lock.json. Putting "config": { "install-strategy": "nested" } in the pkg_name package.json does not work.

boblund avatar Apr 02 '25 14:04 boblund