'Yarn global install: "adonis: command not found"
Installed Adonis with yarn on Ubuntu 18 (running on WSL2 VM):
pomatti@NT-03024:~/Projects/myApp$ yarn global add @adonisjs/cli
yarn global v1.19.1
[1/4] Resolving packages...
[2/4] Fetching packages...
info [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 "@adonisjs/[email protected]" with binaries:
- adonis
Done in 3.29s.
However when I try to run it, the command is not found:
pomatti@NT-03024:~/Projects/myApp$ adonis
adonis: command not found
What is odd is that my package.json commands are working properly and my app is started, but I am not able to call adonis directly in the command line (the global installation).
For example, yarn migration && adonis serve --dev --debug works.
"scripts": {
"serve": "adonis serve",
"migration": "adonis migration:run",
"start": "yarn migration && yarn serve",
"dev": "yarn migration && adonis serve --dev --debug",
"lint": "yarn eslint"
},
Solution 1:[1]
Solution 2:[2]
For CLI tools installed with yarn global to work, you need to have the global yarn bin directory in your PATH. By default the yarn bin dir should be ~/.yarn/bin. To double check if that's right on your system and the adonis executable exists (assuming you've already run yarn global add @adonisjs/cli):
ls ~/.yarn/bin/adonis
(Mine is there).
To add that to my PATH:
cat > ~/.bashrc.d/yarn <<EOF
PATH="$HOME/.yarn/bin:\$PATH"
EOF
chmod +x ~/.bashrc.d/yarn
. ~/.bashrc.d/yarn
Then double check PATH: echo $PATH. Here's mine (after the above - your may not have all of these paths, but so long as it has /home/user/.yarn/bin - where user is your username):
/home/user/.yarn/bin:/home/user/bin:/home/user/.local/bin:/usr/lib/git-core:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | crbast |
| Solution 2 | Jeremy Davis |
