You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] npm link <path> --workspace=<ws> ignores the workspace: dep is attached to the root (and --save writes the root manifest) #9590
npm link <path> --workspace=<ws> does not scope the operation to the target workspace. The linked dependency is attached to the root project instead of the workspace:
With --save (or --save-dev/--save-optional/etc.), the file: dependency is written to the rootpackage.json, not to <ws>/package.json.
Without --save, the dependency is still added to the root node of the ideal tree (so it is placed/hoisted as a root dependency rather than a dependency of the workspace).
npm install <path> --workspace=<ws> --save behaves correctly — it writes the dependency to <ws>/package.json. Only npm link is affected.
This is the underlying reason --workspace appears to have no effect for npm link (see #9115).
Observed
# npm link <path> --workspace=ws-a --save
root package.json -> { "ext-pkg": "file:../ext-pkg" } # WRONG
ws-a package.json -> {} # expected the dep here
npm link <path> --workspace=<ws> should attach the dependency to the target workspace, identical to npm install <path> --workspace=<ws>. With --save, the file: spec should be written to <ws>/package.json, not the root manifest.
Activity
fix(link): scope `npm link <path> --workspace` to the workspace, not …