In case you ended up in a situation where you just installed a global NPM module, but it still throws command not found, here’s what you have to do:
Find out where the global NPM modules are installed by running:
npm prefix -g
Double check that your $PATH does not already contain that value:
If the value is not included, you must update your etc/paths with the NPM location:
sudo vi /etc/paths
Add the value returned by npm prefix -g preceded by /bin
Save the file and exit.
Open a new terminal tab/window and retry the command.
Each time I do a fresh install of the Node Version Management tj/n I end up getting the permission denied when running npm install.
If you also ran into this issue, well, there’s a quick fix.
The issue is caused by the Node Version Management for which the owner is the root.
The two following steps will help you continue in peace 😀
Returns the install location of the Node Version Management package. e.g. /Users/username/n
sudo chown -R $(whoami) <PATH_WHICH_N>
Sets the current user as owner.
You can now install the NPM packages without the power of sudo.
Until you properly config your environment you’ll probably run into the command not found error when trying to run globally installed NPM modules.
Solution for Linux and OSX:
Step 1 – check if the path is correct
You need to have
/users/<ME>/.npm-global/bin in your $PATH
If the printed string doesn’t contain the above path, continue to Step 2
Step 2 – add npm global install path
We need to adjust the $PATH in order to contain the path to the NPM global module folder:
Step 3 – reload .bashrc
The .bashrc file is usually only reloaded on startup. Run the bellow command to reload it again after you made the changes from Step 2.
That’s all. Your global NPM modules should now work in your terminal.