yarn icon indicating copy to clipboard operation
yarn copied to clipboard

Add command to show linked packages

Open wclr opened this issue 8 years ago • 54 comments

I think it would be useful to have a command that shows currenlty linked packages (using yarn link [package]) in current project.

wclr avatar Nov 07 '16 19:11 wclr

How about something similar to global?

Usage: yarn link [add|ls|remove] [flags]

torifat avatar Nov 13 '16 19:11 torifat

yarn link [add|ls|remove] [flags]

Yes I think that would be very explicit and nice.

wclr avatar Nov 13 '16 20:11 wclr

Any movement or workarounds on this one?

tnrich avatar Aug 27 '17 22:08 tnrich

I found this workaround: ls -l node_modules | grep ^l

tnrich avatar Aug 27 '17 22:08 tnrich

@tnrich nice solution, is there a more general one which supports namespace? e.g. node_modules/@myCompany

bingzheyuan avatar Aug 30 '17 07:08 bingzheyuan

@bingzheyuan you can try

( ls -l node_modules ; ls -l node_modules/@* ) | grep ^l

(copied from this SO question)

jlegrone avatar Sep 18 '17 22:09 jlegrone

@jlegrone checked, works great, thanks a lot

bingzheyuan avatar Sep 20 '17 07:09 bingzheyuan

Is this feature still being considered? @kittens

benedikt-roth avatar Nov 14 '17 15:11 benedikt-roth

+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

sweth avatar Dec 04 '17 15:12 sweth

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.

codekiln avatar Dec 05 '17 20:12 codekiln

just searched to see if this exists...

erichaus avatar Jan 08 '18 22:01 erichaus

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.

MikeTaylor avatar Jan 30 '18 13:01 MikeTaylor

One might think that the ~/.yarn-config/link directory would contain the relevant information -- but it's empty.

MikeTaylor avatar Jan 30 '18 13:01 MikeTaylor

@MikeTaylor I think you're looking for ~/.config/yarn/link

vwong avatar Feb 01 '18 23:02 vwong

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.)

MikeTaylor avatar Feb 02 '18 07:02 MikeTaylor

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 avatar Mar 31 '18 10:03 retog

@retog if you're using Windows it looks like the directory you're looking for is: C:\Users\<userName>\AppData\Local\Yarn\config\link.

TomGault avatar Apr 23 '18 16:04 TomGault

Thanks @TomGault , the links are there.

retog avatar Apr 24 '18 07:04 retog

hope can have this lol for global and local

bluelovers avatar Aug 25 '18 19:08 bluelovers

This would massively help debugging when working on cross repo integration! (Situation I currently find myself)

Minothor avatar Sep 19 '18 09:09 Minothor

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/

victorb avatar Sep 19 '18 13:09 victorb

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

bluelovers avatar Oct 01 '18 02:10 bluelovers

On my PC running Windows 10, yarn links are here: ~\AppData\Local\Yarn\Data\link\

marckassay avatar Oct 10 '18 14:10 marckassay

any updates ?

lili21 avatar Oct 19 '18 11:10 lili21

find node_modules -type l | grep -v .bin and find ~/.config/yarn/link -type l are helpful for finding linked and linkable modules, respectively.

hubgit avatar Nov 20 '18 22:11 hubgit

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'}

marckassay avatar Nov 20 '18 23:11 marckassay

This will be very helpful if provided. Is there any progress?

aprilandjan avatar Nov 23 '18 03:11 aprilandjan

+1

dannypk avatar Dec 05 '18 14:12 dannypk

+1

lifayt avatar Dec 12 '18 15:12 lifayt

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).

octref avatar Jan 01 '19 06:01 octref