With npm, we can easily install the package globally by passing -g
flag with administrative rights. But when I tried with yarn global add
it showed me command not found. After digging around. I found I haven’t specified yarn path in my .bashrc file. If you’re using different shell like zsh or something, the file name will change.
I quickly opened the .bashrc file and added the below line in bottom.
PATH=$PATH:/home/USERNAME/.yarn/bin
Make sure to change the USERNAME with your actual username which you can get by running whoami
in your terminal.
After pasting in the file and closing it. I ran this command.
yarn global bin
After all these, I tried running the package command. This time it ran smoothly.
Hope it works for you.