Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
665 views
in Technique[技术] by (71.8m points)

yarnpkg - How to display yarn globally installed packages?

I am using MacOs Sierra 10.12.4 and I have installed yarn by brew install yarn and it's version is yarn version v0.23.2

I installed angular-cli, bower and ionic using yarn global add <package-name>

Then I use yarn global ls to display globally installed packages and I am expecting to see the above installed packages but yarn gives me this:

$ yarn global ls                                                               
yarn global v0.23.2
warning No license field
?  Done in 0.99s.

Then i check yarn global bin and get path /Users/myusername/.config/yarn/bin and I go to the directory and see softlinks:

lrwxr-xr-x  1 myusername  staff    38B 19 Apr 10:17 bower -> ../global/node_modules/bower/bin/bower
lrwxr-xr-x  1 myusername  staff    42B 19 Apr 10:21 cordova -> ../global/node_modules/cordova/bin/cordova
lrwxr-xr-x  1 myusername  staff    38B 19 Apr 10:20 ionic -> ../global/node_modules/ionic/bin/ionic
lrwxr-xr-x  1 myusername  staff    41B 19 Apr 10:15 ng -> ../global/node_modules/angular-cli/bin/ng

Apparently all packages were installed and saved under /Users/myusername/.config/yarn/global/node_modules

I searched the following threads https://github.com/yarnpkg/yarn/issues/2446

Tried appending below paths but still not work:

YARN_BIN=$HOME/.config/yarn/bin  # `yarn global bin` result
export PATH=$YARN_BIN:$PATH
export PATH=$PATH:$HOME/.config/yarn/global/node_modules/.bin

Can anyone help? What should I do and how to display the globally installed packages?

question from:https://stackoverflow.com/questions/43501514/how-to-display-yarn-globally-installed-packages

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

yarn global list is currently broken, too. See the related issue.

Currently I directly list Yarn global packages folder content:

  • Windows: %LOCALAPPDATA%/Yarn/config/global
  • OSX and Linux non-root: ~/.config/yarn/global
  • Linux if logged in as root: /usr/local/share/.config/yarn/global

Update June 22, 2020

As of May 12, 2017 this problem has been resolved. See issue and pull request.

So you can use yarn global list to list all globally installed packages.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...