Yarn: "command not found" when executing globally installed package

Created on 25 May 2017  路  6Comments  路  Source: yarnpkg/yarn

Hi,

I'm trying to install Angular CLI globally with yarn, but I can't seem to get it to work (ng -v doesn't work).

I get the following warning, and ng -v doesn't work - not on the same terminal window, not on a new terminal window, and not after closing this terminal window and opening a new one :(

$ cat /etc/centos-release
CentOS release 6.5 (Final)
$ node -v
v6.10.3
$ yarn -v
yarn install v0.25.2
$ yarn global add @angular/cli
yarn global v0.25.2
warning No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
warning [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "@angular/[email protected]" with binaries:
      - ng
warning No license field
Done in 7.46s.
$ ng -v
bash: ng: command not found

I saw a similar issue but it was supposedly fixed a long time ago.

Does anyone know what to do please?

triaged

Most helpful comment

Try running yarn global bin and check that the directory it prints out is on your PATH.

Also try with sudo (ie. sudo yarn global add @angular/cli) as there may still be an issue with Yarn incorrectly using the Node.js installation directory as the executable directory, which is not writable by normal users.

All 6 comments

Try running yarn global bin and check that the directory it prints out is on your PATH.

Also try with sudo (ie. sudo yarn global add @angular/cli) as there may still be an issue with Yarn incorrectly using the Node.js installation directory as the executable directory, which is not writable by normal users.

I am having a similar error on a travis build

@epicallan - Do you mean the "fsevents" thing? The fsevents warning can be ignored - fsevents is only for Mac OS, so it will fail to install on all other platforms.

Or do you mean the "command not found" after installing a global module?

@Daniel15 - I am having an error with "fsevents" thing. Yarn just hangs.
Yarn v0.24.5
The yarn command i run:
yarn install --ignore-optional


warning [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...

@Daniel15 I have realized the "fsevents" thing was being introduced by one particular dev dependence install that i don't even need for my builds. Removed it and everything works fine.

Was this page helpful?
0 / 5 - 0 ratings