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
pnpm link
and pnpm unlink
documentation page could be better?
#4640
Comments
And how do I preserve links in new installations of the repo? |
I will be honest I have never been able to use |
|
Even as a longtime user of NPM and yarn also have their respective tutorial blog posts and articles, usually as the second Google result after the official docs. Meanwhile this issue (to improve the docs) is the second result, not a good sign. The most useful resources for me on This is a great project, and I appreciate everyone's work on it! I know eventually we'll have the docs we all want. |
The stack overflow solution outlined here was what I was looking for.
|
With this context
I want to dev mylib with local live testing in myapp, without changing myapp:package.json dependencies. To achieve this, in /home/projects/myapp I run It works even if mylib name isn't To have the same result, you can also make the link global (register your local copy in your local pnpm store then using it)
Using this way can be easier if mylib is used in many places and you want to switch quickly from a mylib git worktree to another one (just have to run (same reply made on the stackoverflow post) |
@nachoaldamav has improved the link and unlink command docs: |
Is there a difference between The docs after the above PRs now have a confusing inconsistency between the description and example:
These seem to be saying the opposite thing. The description says "be inside the folder you want a package to be linked to, then tell the command where that package that you want linked is located" The example is saying "be inside the package you want linked, and then tell the command where the package you want it linked to is located. Which is the opposite of what the descriptions says. |
I made this diagram to show how it works # The current directory is foo
pnpm link ../bar
- foo
- node_modules
- bar -> ../../bar
- bar
# The current directory is bar
pnpm link --dir ../foo
- foo
- node_modules
- bar -> ../../bar
- bar
# You can test it here https://stackblitz.com/edit/stackblitz-starters-1bwgba |
I think the docs page could then benefit from another example that shows the opposite use, since right now the example is demonstrating only one of the two possible ways to use it while the description is talking about the other |
The documentation pages for
pnpm link
andpnpm unlink
needs some elaboration, please.Topics that could be covered/improved:
pnpm link <dir>
and the other options. What is the usecase?pnpm link <dir>
and--dir
option is potentially confusing. For example, my experiments withpnpm link --global --dir c:\some\other\folder
did not have the effect I expected. (I don't really know what it did, but it didn't register c:\some\other\folder's package repo globally)--global
linking - 1) from the dependency to register it globally, 2) from the dependentunlink
: "If called without arguments, all linked dependencies will be unlinked." Is this global to the machine? Is it just for dependents? Or just for dependencies? Or both, for a particular working directory?The text was updated successfully, but these errors were encountered: