Yarn: Cannot execute globally installed packages (Windows)

Created on 21 Jun 2017  路  6Comments  路  Source: yarnpkg/yarn

On Windows,
"yarn global add typescript" installs to %LOCALAPPDATA%Yarnconfigglobalnode_modules (actually expanded to "c:usersAppDataLocalYarn...) - executable scripts go that folder's subfolder .bin

However, "yarn global bin" shows %LOCALAPPDATA%Yarnbin, or "c:usersAppDataLocalYarnbin", respectively. This folder doesn't exist at all.

What is the expected behavior?
I don't know where you really want to put the global modules. However, since "c:usersAppDataLocalYarnbin" is appended to the user's PATH environment variable I would suppose this is the right folder.

Strangely enough, since "yarn config get prefix" yields "undefined", I tried "yarn config set prefix "c:usersAppDataLocalYarnbin"" (which obviously is the above listed global bin). Then global modules are indeed installed there.

Please mention your node.js, yarn and operating system version.
Behaviour is the same for yarn 0.24.6 and 0.26.1, node 8.1.2, Windows 10 1703 - yarn had been installed first by chocolatey, but I tried the msi as well.

cat-bug help wanted needs-confirmation os-windows triaged

Most helpful comment

I fixed this by adding the result of yarn global bin to my environment variables for the system (not the user, where it already was, but didn't work).

All 6 comments

For the records - since I've been playing around with the prefix config, I cannot reproduce this bug anymore. I removed the prefix config and it still installs fine.

For me it looks like yarn hadn't been able to write to "c:usersAppDataLocalYarnbin", but now it is. I cannot tell, however, what changed :-(

I cannot reproduce this bug anymore. I removed the prefix config and it still installs fine.

Closing then :)

I fixed this by adding the result of yarn global bin to my environment variables for the system (not the user, where it already was, but didn't work).

I fixed this by adding the result of yarn global bin to my environment variables for the system (not the user, where it already was, but didn't work).

this worked perfectly

I know this issue is very old but leaving this here for the next Google search that leads someone here:

I added this to my .bashrc file:

# add this if yarn global packages don't work
export PATH="$(yarn global bin):$PATH"

Then reload the file with:

# path to .bashrc file
. /home/my_username/.bashrc

I know this issue is very old but leaving this here for the next Google search that leads someone here:

I added this to my .bashrc file:

# add this if yarn global packages don't work
export PATH="$(yarn global bin):$PATH"

Then reload the file with:

# path to .bashrc file
. /home/my_username/.bashrc

thanks this worked perfectly!

Was this page helpful?
0 / 5 - 0 ratings