69

I am using macOS Sierra 10.12.4 and I have installed yarn by brew install yarn and its 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 the 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?

BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91
Haifeng Zhang
  • 30,077
  • 19
  • 81
  • 125

4 Answers4

92

yarn global list

The command had issue in Spring 2017, that had been fixed.

2017 workaround

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.

Paul Verest
  • 60,022
  • 51
  • 208
  • 332
Andrea Carraro
  • 9,731
  • 5
  • 33
  • 57
  • @toomuchdesign thanks for your reply, I knew `yarn global list` was abandoned.. seems like checking `~/.config/yarn/global` is the only way to list globally installed packages..thanks again. – Haifeng Zhang May 05 '17 at 17:05
  • 2
    Just used global list now and it seems not broken anymore. – giovannipds Feb 19 '20 at 21:25
  • Just used Global list now and it seems to only return the Yarn version number, and the Windows directory is now `%LOCALAPPDATA%/Yarn/Data/global` – Aj Otto Jan 13 '21 at 07:58
15

yarn global list has been fixed, see issue and pull request.

Salim Mahboubi
  • 561
  • 7
  • 25
3

I have did some research for a couple of days but haven't get quite helpful solutions. #2224 #3142 and some other Github issues relate to this.

This is how I get the global installed packages so far:

  1. go to ~/.config/yarn/bin, it shows the packages but no version tags.
  2. go to ~/.config/yarn/global and run cat package.json to display the installed packages

Content:

{
    "dependencies": {
    "angular-cli": "^1.0.0-beta.28.3",
    "bower": "^1.8.0",
    "yo": "^1.8.5",
    "browser-sync": "^2.18.8",
    "cordova": "^6.5.0",
    "generator-jhipster": "^4.3.0",
    "ionic": "^2.2.2",
    "ts": "^0.0.0",
    "typescript": "^2.2.2"
    }
}

To check whether the info is accurate, I run yarn global remove yo, then yo is gone in the ~/.config/yarn/bin folder and then I cat package.json again and yo has removed from the file as well.

  "dependencies": {
    "angular-cli": "^1.0.0-beta.28.3",
    "bower": "^1.8.0",
    "browser-sync": "^2.18.8",
    "cordova": "^6.5.0",
    "generator-jhipster": "^4.3.0",
    "ionic": "^2.2.2",
    "ts": "^0.0.0",
    "typescript": "^2.2.2"
  }
}

npm works perfectly on my machine but yarn is much faster, that's why I don't want to go back to npm... Hope someone can provide more elegant way to achieve this.

Haifeng Zhang
  • 30,077
  • 19
  • 81
  • 125
2

I found my solution here in windows 10:

C:\Users\{YOUR_USERNAME}\node_modules\.bin

just add this path to my environment variables

Mohammadtz
  • 92
  • 1
  • 5