-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
npm
allows to define a dependency using git
or GitHub URLS:
- https://docs.npmjs.com/cli/v10/configuring-npm/package-json#git-urls-as-dependencies
- https://docs.npmjs.com/cli/v10/configuring-npm/package-json#github-urls
However, I think there's a limited or buggy functionality when trying to install a dependency from a git repository that contains a workspace.
For example, here's the main package:
{
"dependencies": {
"@org/dep-y": "git://github.com/org/monorepo.git"
}
}
The monorepo
project contains a root package.json
that defines a workspace:
{
"name": "@org/monorepo",
"workspaces": ["packages/**"],
"publish": false
}
And packages/
contains the library dep-y
:
{
"name": "@org/dep-y",
"publish": true
}
Current behaviour: npm
links @org/dep-y
to @org/monorepo
Expected Behavior
Expected behaviour: npm
links @org/dep-y
to @org/dep-y
inside packages/dep-y/package.json
Steps To Reproduce
-
Have a setting like this:
For example, here's the main package:{ "name": "external-lib", "dependencies": { "@org/dep-y": "git://github.com/org/monorepo.git" } }
The
monorepo
project contains a rootpackage.json
that defines a workspace:{ "name": "@org/monorepo", "workspaces": ["packages/**"], "publish": false }
And
packages/
contains the librarydep-y
:{ "name": "@org/dep-y", "publish": true }
-
Run
npm i
inside theexternal-lib
lib -
Look that the symbolic link inside
node_modules/@org/dep-y
points to the whole workspace -
Try to import the library
import("@org/dep-y")
see errors because it usespackage.json
of the workspace
Environment
- npm: 10.2.4
- Node.js: v20.11.1
- OS Name: macOS
- System Model Name: Macbook Pro
- npm config: I have none