-
-
Notifications
You must be signed in to change notification settings - Fork 951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't install dependencies when one of them is linked from global #3584
Comments
Is myown-package getting added in dependencies of project's package.json? Can you once check in these lines also.. I am also facing the same issue |
@rahulkandikatla Yes it is. And it is a important point here. I guess pnpm has wrong priority adjustments: it is first looks to npm registry and only then (if at all) looks to global directory for packge linking. My thoughts is that pnpm just fail on first error instead of trying other variants (global packages in this case). |
pnpm package.json should clearly indicate when a package is linked or when it's from a repository.
Packages added by linking should indicate:
Then pnpm should handle linked packages similar to workspace packages like skipping install command. |
If I link a package from a local directory with:
Then it is listed in the If I then do:
After that there is no trace of it being linked. |
Maybe pnpm should simply check if the package in |
After giving more thought to how this feature would be used, I completely agree with this idea of checking in 'node_modules' for symlinks - rather than any kind of modifications to the package.json (e.g. link: syntax). IMO it should be up to each individual developer whether they are using a locally linked package (via |
This is not an elegant solution, but while we wait on a fix for this bug, here's a workaround that may help someone: https://gist.github.com/gouldingken/332abc5f95a9e59c685cb15461b698e1 |
Is there any timeline on this issue being fixed? For me it's a fairly major blocker for development using local packages right now... |
What I ended up doing was making a script to regular link my local packages (the list of linkable packages is set by an env variable). This will run any prepare scripts in the linked packages (and I think postinstall too?), unlike linking via a global link but it works without modifying any packages. https://gist.github.com/AlansCodeLog/770d80bc7e51d264970dff75cb04ffc6 |
Workaround without postinstall - MacOSI'm sure this is doable on windows and linux as well.
link:/Users/<user>/Library/pnpm/global/5/node_modules/<library>
{
"dependencies": {
"<lib>": "link:/Users/<user>/Library/pnpm/global/5/node_modules/<lib>"
}
} This should allow pnpm to install other deps. Works for me at least. |
In pnpm way what I did is: "dependencies": {
+ "@scope/my-lib": "link:../path-to-my-libs/packages/my-lib"
} CI/CD handle local lib part too. "dependencies": {
- "@scope/my-lib": "link:../path-to-my-libs/packages/my-lib"
+ "@scope/my-lib": "^0.0.1"
} while local developing (my-lib): # link to global node_modules
workspaces/my-lib >pnpm link --global
# link to local
workspaces/my-project> pnpm link --global @scope/my-lib This is ok for me, for one or two packages, but it does has more packages developed in local, and published into private registry. In conclusion, there maybe has a way to simplify the pipe (in my humble opinion): while link the local lib +@scope/my-lib=pnpm-link:../path-to/my-lib Then, project install from the path automaticlly, the lib package version flag can keep in package.json and output log: pnpm links several packages:
@scope/my-lib@^0.0.1 <- path-to/my-lib "dependencies": {
+ "@scope/my-lib": "^0.0.1"
} if link the local lib is a misstake, developer should manully unlink: > pnpm unlink --global @scope/my-lib # or unlink in lib local directory
- @scope/my-lib is droped from global node_modules if there is somthing wrong or features I missed, fell free to comments. |
pnpm version: 6.9.1
Steps to reproduce the issue:
one
andsecond
)one
package to global (pnpm link --global
) and then link it tosecond
(fromsecond
's directory runpnpm install --global one
)package.json
some dependency from npm registry e.g. reactpnpm i
Expected behavior:
Dependencies fron npm registry are installed.
Actual behavior:
Additional information:
node -v
prints: v14.15.3The text was updated successfully, but these errors were encountered: