yarn
yarn copied to clipboard
Add command to show linked packages
I think it would be useful to have a command that shows currenlty linked packages (using yarn link [package]) in current project.
How about something similar to global?
Usage: yarn link [add|ls|remove] [flags]
yarn link [add|ls|remove] [flags]
Yes I think that would be very explicit and nice.
Any movement or workarounds on this one?
I found this workaround: ls -l node_modules | grep ^l
@tnrich nice solution, is there a more general one which supports namespace? e.g. node_modules/@myCompany
@bingzheyuan you can try
( ls -l node_modules ; ls -l node_modules/@* ) | grep ^l
(copied from this SO question)
@jlegrone checked, works great, thanks a lot
Is this feature still being considered? @kittens
+1. It would be nice to have this as a builtin, though for now I have a standalone script that I use:
find node_modules node_modules/\@* -depth 1 -type l -print | while read MODULE ; do
echo "Linked module in use: $MODULE"
done
This is especially helpful on windows, since you really want yarn to tell you what it thinks it's linked to when debugging symlinks on that platform.
just searched to see if this exists...
More important than the case that the comments here provide workarounds for (to me, at least) is the ability to know what yarn links are available -- that is, what directories I have run yarn link in, and so what associations exist between package-names and directories that contain those packages.
One might think that the ~/.yarn-config/link directory would contain the relevant information -- but it's empty.
@MikeTaylor I think you're looking for ~/.config/yarn/link
I was! Thank you so much!
(This does slightly leave me wondering why I have .yarn, .yarn-cache, .yarn-config, .yarnrc and .config/yarn in my home directory, but let it pass.)
Not finding that config
PS C:\Users\me> ls ~/.config
Directory: C:\Users\me\.config
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2018-03-29 5:59 PM configstore
PS C:\Users\me> ls ~/.yarn-config
ls : Cannot find path 'C:\Users\me\.yarn-config' because it does not exist.
The only fie I find is ~/.yarnrc
@retog if you're using Windows it looks like the directory you're looking for is: C:\Users\<userName>\AppData\Local\Yarn\config\link.
Thanks @TomGault , the links are there.
hope can have this lol for global and local
This would massively help debugging when working on cross repo integration! (Situation I currently find myself)
Would indeed be nice with a command like yarn link ls to see all links, especially when you don't remember where a link was created from, so you can remove it.
In the meantime, for macOS/Linux, this should work:
ls -la ~/.config/yarn/link/
i make a stupid way for this, can show current project link list
https://www.npmjs.com/package/yarn-list-link
$ npx yarn-list-link
@node-novel\pattern-split
cjk-conv
lazy-cacache
regexp-cjk
uni-string
On my PC running Windows 10, yarn links are here:
~\AppData\Local\Yarn\Data\link\
any updates ?
find node_modules -type l | grep -v .bin and find ~/.config/yarn/link -type l are helpful for finding linked and linkable modules, respectively.
In an attempt to complement @hubgit post, I believe the following would do for Windows using PowerShell:
Get-ChildItem '.\node_modules\.bin\' | Where-Object {$_.LinkType -eq 'SymbolicLink'}
This will be very helpful if provided. Is there any progress?
+1
+1
Alternatively, implement #710.
If I'm running yarn link and there is already a package registered with the same name, why can't yarn print out the already linked package's path? Additionally, yarn could be smarter by unlinking the other package and link the current one (maybe with a -f flag).