Is there a command to unlink all yarn packages? yarn unlink all

Viewed 13869

I'd like to see a list of all yarn linked packages everywhere on my computer and then run a command to unlink all of them. Can anyone help me out here?

Thanks!

5 Answers

Don't know if this is the yarn way to do things, but I just :

rm -rf ~/.config/yarn/link/*

You can create aliases

alias yarn-linked="find . -type l | grep -v .bin | sed 's/^\.\/node_modules\///'"
alias yarn-unlink-all="yarn-linked | xargs yarn unlink && yarn install --check-files"

Credit hubgit

There is an Issue for this feature.

The only surefire way I know of is to nuke node_modules:

rm -rf node_modules && yarn

I know, I know, horrible solution. If someone knows a better way, please inform.

Links are registered in ~/.config/yarn/link. To reverse this process or unlink, simply use:

yarn unlink

or

yarn unlink [package]

EDIT:

You can try by add following in bash.rc:

alias yarn-linked="find . -type l | grep -v .bin | sed 's/^\.\/node_modules\///'" 
alias yarn-unlink-all="yarn-linked | xargs yarn unlink && yarn install --check-files" 
Related