The solution to – Bash: command not found
So you are trying to install your application globally by type “npm install -g xxx”. The installation was successful but when you ran the command in the Terminal and an error popup “xxx: command not found”.
What is the problem here?
The problem is you might have installed your application in your local folder that is /Users/YOURUSERNAME/node_modules instead in the global NPM folder.
How to check if you have installed it in the right folder?
Let type “npm root” or “npm root -g” and see what it returns.
If you see /Users/YOURUSERNAME/node_modules, that mean you have installed it in the wrong folder.
The expected result should be /usr/local/lib/node_modules folder.
How to solve this problem?
So what you need to do is to update the “npm config prefix” by typing this in your Terminal: npm config set prefix /usr/local
Now try typing npm root -g in the terminal and see if the return result is /usr/local/lib/node_modules.
Finally, go back to your Terminal and try typing npm install -g xxx to install your application again.
You should be able to install it without any error now. Never will “command not found” appear again. Happy coding.