Yarn global install: "adonis: command not found" - yarnpkg

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 fsevents#1.2.9: The platform "linux" is incompatible with this module.
info "fsevents#1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "#adonisjs/cli#4.0.12" 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"
},

Try to install with NPM. Command:
> npm i -g #adonisjs/cli
Official documentation

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

Related

Usage Error When run "yarn start" on yarn berry project

Our team decides to use yarn berry on our project, and one in my team initialize project. So I cloned the project on my local and run "yarn start" in terminal But it is not work.
This is the Error message.
Usage Error: Couldn't find the node_modules state file - running an install might help (findPackageLocation)
I tried "yarn install" and it worked but node_modules and other things are generated.
You likely have to first do the command:
yarn install
Then
yarn start

Using node-sass watch option with yarn start script

so i am trying to run sass with yarn start at the same time.
when i run yarn build:sass in command line , it triggesr the sass watch and if I make any changes into the sass it will update the css file however it wont start the project "yarn start doesnt work" is there anyway for me to run it all in one console?
"build:sass": "node-sass src dist",
"watch:css": "yarn build:sass && yarn build:sass -- -w && yarn start",
"start": "PUBLIC_URL=/ react-scripts start",
for anyone out there u can run this using run all
install the package first and then have it run after
start": "npm-run-all -p watch:sass start:react"

Why nx serve doesn't work when installed globally with Yarn?

I initiated an Nx workspace using npx:
npx create-nx-workspace
I get this after nx finished bootstrapping my workspace:
This means that you might have to use "yarn nx" or "npx nx" to execute command
s in the workspace.
Run "yarn global add nx" or "npm install -g nx" to be able to execute command
directly.
I want execute command directly and want to use yarn so:
yarn global add nx
and get success message:
yarn global v1.22.10
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "nx#12.5.8" with binaries:
- nx
Done in 9.40s.
I cd into my workspace, and try to serve my 'todos' app using the nx cli that I installed previously:
cd myorg
nx serve todos
but I get this error:
bash: nx: command not found
I restarted my terminal and tried to serve again but got the same error. serve works if I do yarn nx serve todos, but, I would love to learn why and how I can make the direct command work with Yarn.

yarn dev error Command failed with exit code 1 when running guest-book example

I'm trying to use yarn dev to run the guest-book example following the guest-book example, but this is what I got:
Computer#Summerbook MINGW64 ~/Documents/VS Code Projects/near apps/guest-book (master)
$ yarn dev
yarn run v1.22.11
$ yarn build:contract:debug && near dev-deploy && nodemon --watch assembly -e ts --exec yarn dev:start
$ asb --target debug
'asb' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I think the error is this:
'asb' is not recognized as an internal or external command,
operable program or batch file.
The script in package.json is:
"scripts": {
"build": "yarn build:contract && yarn build:web",
"build:contract": "asb",
"build:contract:debug": "asb --target debug",
"build:web": "parcel build src/index.html --public-url ./",
"deploy": "yarn build && near deploy && gh-pages -d dist/",
"dev": "yarn build:contract:debug && near dev-deploy && nodemon --watch assembly -e ts --exec yarn dev:start",
"lint": "eslint \"./**/*.js\" \"./**/*.jsx\"",
"start": "yarn deploy && parcel src/index.html",
"dev:start": "env-cmd -f ./neardev/dev-account.env parcel src/index.html",
"test": "yarn build:contract:debug && asp && jest"
I've tried installing dependencies again, but it didn't work.
I believe I'm running under the same directory as package.json.
What can I do here? What causes the error with 'asb'? Thanks for any help!
Moving my answer from the comment:
yarn and then yarn dev should just work. Try using regular Windows terminal (cmd or powershell).
Your VS code seems to use mingw (bash for Windows) environment, which brings its own set of quirks. You may want to switch your default terminal in VS code back to cmd or powershell.
Please try sudo npm install -g asbuild.
Feel free to +1 on https://github.com/near-examples/guest-book/issues/543
It seems that the update to the sdk was never merged with the example. I updated it here: https://github.com/near-examples/guest-book/pull/539#pullrequestreview-721177317
Please try again and let me know if the issue is fixed. Thanks!

How to uninstall Yarn from a project

I'm a bit confused.
I accidentally installed yarn in a project. I just ran the command yarn that installed the yarn in the project. How do I uninstall yarn from the project?
Do I type in npm uninstall yarn? to uninstall it from a project?
I looked at other solutions and I'm confused.
Run npm uninstall yarn make sure it no longer is listed in your package.json
Delete the yarn.lock file if there is one
If in linux (similar for others I guess):
cd project_directory
Run "npm uninstall yarn"
rm -rf .yarn
rm .yarnrc.yml
rm yarn.lock
in package.json: delete "yarn" lines
in .gitignore (if present): delete "yarn" lines
in README.md (if present): change "yarn" to "npm"
run "grep -irl yarn ." to find any other references

Resources