-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
The namespace is being dropped when linking workspace packages which results in them not being found when attempting to import from them.
I've made a minimal repro here: https://github.com/iansu/npm-linked-install-repro
I have two packages in a workspace in this repo:
@iansu/package-a@iansu/package-b
@iansu/package-b has a dependency on @iansu/package-a
When no install strategy is specified this is what the root node_modules directory looks like:
❯ tree node_modules
node_modules
└── @iansu
├── package-a -> ../../packages/package-a
└── package-b -> ../../packages/package-b
3 directories, 0 filesIn this case nothing is installed in package-b's node_modules directory
When install-strategy=linked is specific this is what the root node_modules directory looks like:
❯ tree node_modules
node_modules
├── package-a -> ../packages/package-a
└── package-b -> ../packages/package-b
2 directories, 0 filesAdditionally this is what package-b's `node_modules directory looks like:
❯ tree packages/package-b/node_modules
packages/package-b/node_modules
└── package-a -> ../../package-a
1 directory, 0 filesWhen I try to import from @iansu/package-a I get an error because neither node_modules/@iansu/package-a or packages/package-b/node_modules/@iansu/package-a exist
Expected Behavior
The contents of node_modules should include the namespace and produce a tree similar to the one produced when not using install-strategy=linked
Steps To Reproduce
- Clone the repro
- Run
npm install --install-strategy=linked cd packages/package-bnode index.js- Observe import error
If you delete node_modules and run npm install again without install-strategy=linked you will not get the import error
Environment
- npm: 9.4.1
- Node.js: 16.15.0
- OS Name: macOS
- System Model Name: M2 MacBook Air
- npm config:
; "user" config from /Users/iansu/.npmrc
//registry.npmjs.org/:_authToken = (protected)
init-author-email = "ian@<domain>"
init-author-name = "Ian Sutherland"
init-license = "MIT"
init-version = "0.0.0"