Today, I installed an npm package globally, no problem here.
But, when I execute the package, there comes an error:
~ ❯❯❯ yo zsh: command not found: yo
So, it means that the system doesn’t realize the path to my package. I confirm by using:
~/W/C/htnmaruko ❯❯❯ echo $PATH /Users/duchoang/.rbenv/shims:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin
So that, we need to export the path to where my package is lying in.
Because I installed by -g parameter, so it is lying in global npm. In my case, it is being in ~/.npm-global.
1. Export your path in ~/.zshrc (in case of using zsh, otherwise using ~/.bashrc) by print it to your ~/.zshrc or ~/.bashrc (in case of not using zsh) file:
~/.n/bin ❯❯❯ printf "\nexport PATH=\"\$PATH\":%s\n" ~/.npm-global/bin >> ~/.zshrc
Or just editing with vi:
~ ❯❯❯ vi /Users/duchoang/.zshrc
2. Now, fire up the changes:
~ ❯❯❯ . ~/.zshrc
3. And finally, the problem gets solved, the result we have:
Now we can get back to our work.