Skip to content
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

About Pnpm link #4439

Open
qiYuei opened this issue Mar 15, 2022 · 6 comments
Open

About Pnpm link #4439

qiYuei opened this issue Mar 15, 2022 · 6 comments

Comments

@qiYuei
Copy link

qiYuei commented Mar 15, 2022

pnpm version: 6.23.1

Code to reproduce the issue:

When I develop A package called A with PNPM, there is an NPM project B that depends on this A. When I debug this A in project B, I used to just to npm link in PROJECT A and then npm link B in project B. I see that link directives are also in the PNPM documentation, so I try to use pnpm link --global -C in Project A and then pnpm link --global A in project B and find that nodemodules in project B do not have Link A

Expected behavior: B link A

Actual behavior:

A call pnpm link --global -C
image
image
B call pnpm link --global A
image
image

Additional information:

  • node -v prints:14.16.1
  • Windows, macOS, or Linux?:windows
@zkochan
Copy link
Member

zkochan commented Mar 16, 2022

You probably need to run pnpm link --global. The -C option is not needed.

Alternatively, you may run in the directory of the B project:

pnpm link ../<relative path to A>

@qiYuei
Copy link
Author

qiYuei commented Mar 16, 2022

Thank you for your answer . but i tried to run as you said pnpm link --global in project A . Then run pnpm link --global @mom/utilsin project B.
image

A

 E:\git\mom-component\packages\com> pnpm link --global

C:\Users\QiYuei\AppData\Roaming\npm\pnpm-global\5:
- @mom/components
+ @mom/components 0.0.27 <- E:\git\mom-component\packages\com
 E:\git\mom-component\packages\com>

B

 WARN  Local dependency not found at C:\Users\QiYuei\AppData\Roaming\npm\pnpm-global\5\node_modules\@mom\components

C:\Users\QiYuei\AppData\Roaming\npm\pnpm-global\5:
- @mom/components 0.0.27

A package.json

 {
   "name":"@mom/components",
    "files": ["library" ],
    "dependencies": {
    "@mom/utils": "workspace:*",
    }
}

However, I found A strange phenomenon. For example, I changed the package name of A to '@lo/ d', which could be successfully linked by B

image

image

What are the reasons for this?

@qiYuei
Copy link
Author

qiYuei commented Mar 16, 2022

It was resolved after I deleted the folder C:\Users\QiYuei\AppData\Roaming\npm\pnpm-global

@frank-dspeed
Copy link

@zkochan this can be closed i readed it and the user sayed it is solved just wanted to ping you to clean up issues.

@qiYuei
Copy link
Author

qiYuei commented Apr 1, 2022

@zkochan this can be closed i readed it and the user sayed it is solved just wanted to ping you to clean up issues.

I find that I often need to delete this folder when I restart or re-pnpm link --global, but it always fails to link without deleting it. Is there something wrong with my operation? @zkochan

delete the folder C:\Users\QiYuei\AppData\Roaming\npm\pnpm-global

@JasonKleban
Copy link

JasonKleban commented Apr 28, 2022

I have experienced this same confusing WARN  Local dependency not found at ... which results in the dependency being removed (at least indicated by the output). Deleting the pnpm-global and re-global linking the source-repo also worked for me until unlinking. #4638

Side note: I'm pretty sure I know by now how npm-link is supposed to work and that I have a healthy expectation of how pnpm-link is supposed to work - but I find the pnpm-link documentation page to still be quite confusing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants