Can not run globally installed packages which are installed with yarn
sharikovvladislav opened this issue · 38 comments
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
I can not run globally installed packages (uglifyjs, eslint etc).
Looks like there are problems with path. When I run (you full steps can see below) commands I get errors about path is incorrect. Path is: /d/Dev/nodejs/C:/Users/Vlad/AppData/Local/Yarn/config/global/node_modules/.bin/uglifyjs
.
It is not problem with uglifyjs
. If I will install eslint
globally or something like that I am getting same behaviour.
I am trying to do this in Git Bash terminal (MINGW64). If I try to run same command in cmd, cmd window is just disappearing. I also tried to create .cmd
file and run commands from this file via: cmdFileName >> xx.txt
. I got this in output:
c:\Users\Vlad>eslint --help
c:\Users\Vlad>"$basedir/C:/Users/Vlad/AppData/Local/Yarn/config/global/node_modules/.bin/eslint.cmd" "$@"
c:\Users\Vlad>exit $?
If the current behavior is a bug, please provide the steps to reproduce.
- Install yarn with windows installer.
- Install
uglify-js
(or anything else) globally (from npm):
Output is:
Vlad@VladPC MINGW64 /
$ yarn global add uglify-js
yarn global v0.17.10
warning No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed uglify-js@2.7.5 with binaries:
- uglifyjs
warning No license field
Done in 1.71s.
- Use installed package
Vlad@VladPC MINGW64 /
$ uglifyjs
/bin/sh: /d/Dev/nodejs/C:/Users/Vlad/AppData/Local/Yarn/config/global/node_modules/.bin/uglifyjs: No such file or directory
What is the expected behavior?
I expect that I can run uglifyjs
(or eslint
or any other pacakges) command without errors after it.
Please mention your node.js, yarn and operating system version.
NodeJS v 7.0.0
Yarn v v0.17.10
OS v Windows 7 Ultimate x64
Might be specific to Git Bash or MinGW... Try it in a regular cmd.exe and see if it works there?
+1
NodeJS v 7.0.0
Yarn v v0.18.1
Windows 7 Ultimate x64
after yarn global add http-server
http-server.cmd create at node.exe root dir
"$basedir/../../Users/{username}/AppData/Local/Yarn/config/global/node_modules/.bin/http-server.cmd" "$@"
exit $?
console can't known the $bashdir
path
Hm. I am trying to get what is /d/Dev/nodejs/
prefix ($basedir). I don't even have this directory at the disk. I don't have any NODE_PATH
env variable (or smth like that) with /d/Dev/nodejs/
I have the same exact problem when installing global packages using yarn and I have the same environment as @sharikovvladislav. I tried installing different packages globally with similar results and
none of the packages installed globally are available from cmd. Any help would be greatly appreciated.
Was able to repro. I tracked the issue down to the cmd-shim library.
There is an open PR that solves this.
When I updated my shim to the new code below, it executes as expected.
.....global\node_modules.bin\uglifyjs.cmd
@ECHO.%0 | FINDSTR /C:\ /C:/ >NUL && (
SET dir=%~dp0
) || (
FOR /F %%i IN ('where %0') DO @SET dir=%%~dpi
)
@IF EXIST "%dir%\node.exe" (
"%dir%\node.exe" "%dir%\..\uglify-js\bin\uglifyjs %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%dir%\..\uglify-js\bin\uglifyjs" %*
)
I did run into a separate issue where my Yarn bin path wasn't set correctly. I use the nodist node version manager on this machine. The choco Yarn install set C:\Users\andre\AppData\Local\Yarn\.bin
, however the global installs were actually going to: C:\Users\andre\AppData\Local\Yarn\config\global\node_modules\.bin
.
After manually setting that path, the above workaround script functioned as expected.
I ran into this error as well, but before checking online I decided to try upgrading yarn to see if that fixed my problem - only problem is now the yarn package itself is showing this error. I've tried removing the files manually from the appData\local\yarn folder but it is still showing me the error.
Any idea how I can remove the packages from yarn and use npm instead for now as all of my work code written with angular-cli is now unusable until either this is fixed or I can get my "ng" command to point back to an npm version.
You should check the global folder %LocalAppData%\Yarn\config\global\node_modules%
for any remnants of the globally installed packages using yarn and delete them manually if they are not removed after using yarn remove <package> --global
. Also check the path of your node installation using where node
from command line and delete any script files in the root directory named as your package that were installed globally using yarn
. For example, I have node installed under %ProgramFiles(x86)\ndoejs%
on a 64-bit machine and had to delete both ng
and ng.cmd
files when I installed angular-cli globally using yarn.
@modulexcite ah, I had deleted all the files from the global/node_modules folder but I hadn't deleted the ones from inside the nodejs installation - thanks 😄
@markheron91 Glad to help, hopefully this will get fixed in the next release.
Nope. cmd.exe is not working too. When I write name of package cmd window just disappears.
Now that #1043 landed behaviour described in the quote is gone, but global packages still wont run from MINGW64. (At least it works from cmd
). Here's what I'm seeing:
Iwasawafag@home:/c/dev/whatever (master)
$ where rimraf
C:\Program Files\nodejs\rimraf
C:\Program Files\nodejs\rimraf.cmd
Iwasawafag@home:/c/dev/whatever (master)
$ rimraf
/bin/sh: /c/Program Files/nodejs/../../Users/Iwasawafag/AppData/Local/Yarn/config/global/node_modules/.bin/rimraf: No such file or directory
Contents of both /c/Program Files/nodejs/rimraf
and ~/AppData/Local/Yarn/config/global/node_modules/.bin/rimraf
could be found in this gist
I guess for now I still have to use npm for installation of global packages if I want those to work in Git Bash
+1
In my case yarn install browserify
creates a file D:\DevTools\nodejs\browserify.cmd:
@"%~dp0\C:\Users\myuser\AppData\Local\Yarn\config\global\node_modules\.bin\browserify.cmd" %*
In this case executable path gets resolved to D:\DevTools\nodejs\\C:\Users\myuser\AppData\Local\Yarn\config\global\node_modules\.bin\browserify.cmd
This is obviously wrong.
To clarify, this only happens when I have Yarn installed via Chocolatey, and then Yarn is installed to C:\Program Files (x86)\Yarn\bin\yarn.cmd
If Yarn is installed using npm install -g yarn
, then it gets installed to D:\DevTools\nodejs\yarn.cmd
.
In this case yarn install -g browserify
generates
@"C:\Users\myuser\AppData\Local\Yarn\config\global\node_modules\.bin\browserify.cmd" %*
My Yarn version is 0.19.1.
But can you use them from MINGW64?
@iwasawafag I can run globally installed packages using yarn (v0.19.1) from MINGW64
. FYI, I'm on Windows 7 64-bit with git 2.10.2
I tried to install packages globally with yarn. Everything worked fine. I also tried it from MINGW64.
I think this can be closed as resolved.
@iwasawafag I can run globally installed packages using yarn (v0.19.1) from MINGW64. FYI, I'm on Windows 7 64-bit with git 2.10.2
Hm... I'm also on Win 7 x64 with git 2.10.0.windows.1. This got me to try and change few things and I noticed different behavior:
When %programfiles%/nodejs
is a symlink (in my case managed by nvm-windows (and well, not a symlink, but NTFS junction)) yarn global add <package-name>
creates two scripts in that folder for every globally installed package. For instance, "rimraf" and "rimraf.cmd" both of which just trying to call appropriate script from global-folder
. But whenever it's an actual folder created by Node's installer – no files are being created inside of it.
I don't know in which case it works incorrectly. Considering that Yarn's installer does not add anything else to PATH to make global packages available it looks like it's supposed to create those scripts in node's dir. I fixed it for myself by prepending %localappdata%\Yarn\config\global\node_modules\.bin
to PATH (with %localappdata% resolved).
Perhaps, I should open another issue about this behavior.
@iwasawafag Your problem is probably related to prefix
. What does your yarn global bin
return?
It seems in the absence of a prefix
being provided either through yarn config
or flags, yarn tries to use the process path as a prefix. That's probably not working in your setup.
yarn global bin
says C:\Program Files\nodejs
regardless of whether it's junction point or a directory...... Rrright, it didn't have write access when it was a directory, didn't think of that. Changed permissions, scripts are being generated again.
Now I see what's going on. It has something to do with C:\Program Files\nodejs
being a junction point. When it's a directory - it works fine and when it's not I get same error as I posted above (/bin/sh: /c/-snip-/.bin/rimraf: No such file or directory
). So it's a problem with MinGW64.
Thanks for helping me figure this out
I was using Git along with Cmder which was still using 2.6.3.windows.1. After updating Git to 2.11.0.windows.3 yarn is giving me output again.
This problem occurs again.
Node v6.10.0,
Yarn 0.20.3,
npm v3.10.9,
Git 2.10.2,
OS Win7x64SP1
Node Path:E:\Dev\nodejs
I install yarn with msi installer,when i run"yarn global add vue-cli", the text of"E:\Dev\nodejs\vue.cmd" is
@"%~dp0\C:\Users\HAP\AppData\Local\Yarn\config\global\node_modules\.bin\vue.cmd" %*
It is wrong.
Same issue on Mac, happens every time I run an update alias including yarn global upgrade
. Just gonna use npm now...
yarn 0.21.3
node 7.8.0
windows 7x64
Same problem as @enterit
Example:
Installed gulp as global
Resulting gulp.bat in F:\Program Files\nodejs
@"%~dp0\C:\Users\user.name\AppData\Local\Yarn\config\global\node_modules.bin\gulp.cmd" %*
expands to
@"F:\Program Files\nodejs\C:\Usersuser.namel\AppData\Local\Yarn\config\global\node_modules.bin\gulp.cmd"
The batch file does not like %~dp0 (expands to F:\Program Files\nodejs\) if you remove %~dp0\ and just use @"C:\Users\user.name\AppData\Local\Yarn\config\global\node_modules.bin\gulp.cmd" %*
it works, this is assuming that you have F:\Program Files\nodejs in your path variable which should get added automatically when you install nodejs.
FYI I once installed yarn via npm (I know, bad idea) and yarn global bin
became set to ~/.nvm/versions/node/v5.5.0/bin
(macOS).
I had to use yarn config set prefix /usr/local/
(since /usr/local/bin
is on my $PATH
and therefore will load binaries installed within in) based on the advice suggested here: #630 (comment)
Of course I had to reinstall the package with the binary (in my case gulp) after setting the global binary installation directory.
yarn global remove gulp && yarn global add gulp
But of course the binary I had installed via npm was still being loaded via the nvm binary directory (which I added to my $PATH as well), as I noticed by doing:
$ which -a gulp
/Users/olivierlacan/.nvm/versions/node/v5.5.0/bin/gulp
/usr/local/bin/gulp
This meant I had to remove that file (rm /Users/olivierlacan/.nvm/versions/node/v5.5.0/bin/gulp
) to prevent it from taking precedence on the yarn-installed gulp binary since /usr/local/bin appears later in my $PATH
than /Users/olivierlacan/.nvm/versions/node/v5.5.0/bin
.
Hope that helps others in a similar situation.
Same issue here, but thanks to the above comments I noticed that my bin dir (C:\Users\Tim\appdata\local\yarn\bin
) was not in PATH. I'm not sure why... but at least adding it to PATH was a quick fix.
Interesting, installed latest Yarn 1.2.1 with npm i -g yarn
, and there's no %LocalAppData%\Yarn\bin
directory at all.
Actually, there're only cache
and config
directories in %LocalAppData%\Yarn
.
I found all the shell scripts and .cmd scripts in %LocalAppData%\Yarn\config\global\node_modules\.bin
.
Also, there was no yarn path added to the system path.
I added the .bin path to the system path manually, and everything works fine.
Questions:
- Is
%LocalAppData%\Yarn\bin
deprecated, and yarn will use%LocalAppData%\Yarn\config\global\node_modules\.bin
, or is the missing Yarn/bin path error of installing via npm and should be reported? - Is the missing path in system path error of installing via npm and should be reported?
I do not remember how I originally installed yarn.
To be sure I removed it using npm remove -g yarn
. Then used the windows installer to reinstall it.
Now there is still no bin folder in C:\Users\alex\AppData\Local\Yarn
. It's path does exist in path: C:\Users\alex\AppData\Local\Yarn\bin
.
And global installs are not found when typed in the console.
I've installed polymer-cli globally on a Linux box, but polymer isn't in the path.
~ yarn global add polymer-cli
yarn global v1.3.2
[1/4] Resolving packages...
warning polymer-cli > bower@1.8.2: ...psst! Your project can stop working at any moment because its dependencies can change. Prevent this by migrating to Yarn: https://bower.io/blog/2017/how-to-migrate-away-from-bower/
warning polymer-cli > babel-preset-es2015@6.24.1: 🙌 Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!
warning polymer-cli > polyserve > @types/assert@0.0.29: See https://github.com/DefinitelyTyped/DefinitelyTyped/issues/12826
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "polymer-cli@1.5.7" with binaries:
- polymer
Done in 25.08s.
➜ 19:17 polymer
zsh: command not found: polymer
➜ 19:17 polymer-cli init
zsh: command not found: polymer-cli
➜ 19:17 yarn --version
1.3.2
hm.
Is this problem still exists?
I don't have this even on yarn v 1.0.2. I am not able to reproduce this.
@Daniel15 - I have the path problem using zsh. echo $PATH
doesn't show it including ~/.yarn/bin
.
echo $PATH doesn't show it including ~/.yarn/bin.
This means you haven't added it to your $PATH
. You'll need to edit your ~/.zshrc
file :)
thanks @modulexcite, your #2224 (comment) solve my problem.
in my case, i tried to install globally parcel-bundler
with yarn
, and get this message when I tried to launch parcel
:
"$basedir/../../Users/{username}/AppData/Local/Yarn/config/global/node_modules/.bin/parcel.cmd" "$@"
exit $?
After several failed attempts, I finally came across your comment, found parcel
, parcel.cmd
& parcel.cmd.cmd
files in my node
folder (C:\Program Files\nodejs
), deleted them, and now it works.
I am still experiencing this error on windows while I install any package like @vue/cli globally with yarn global add @vue/cli
it installs correctly but the vue-cli binaries are located at C:\Users\**youruser**\AppData\Local\Yarn\bin
. You have to add this path to the Environment Variables Path to make any package installed globally from yarn to be available on Powershell or CMD.
windows 10 : $ sysdm.cpl
→ Advanced
→ Environment Variables
→ System variables
→ PATH
→ New
→ %LocalAppData%\Yarn\Data\global\node_modules\.bin\
→ restart Command Prompt
Thanks for spot that. But I still miss why that path should have been manually added
This is still correct. I just tested with npm install -g @vue/cli
- works great. Same with yarn: yarn global add @vue/cli
- everything is installed, but vue
can't be called, because it's not in the path.
Ubuntu 18.04, nvm-> node 12.5.0.