To fix global Node modules not found with JavaScript, we set the NODE_PATH environment variable.
We run
echo $NODE_PATH
to print the value of the NODE_PATH environment variable.
If it’s empty, we add
nano ~/.bash_profile
export NODE_PATH=`npm root -g`
source ~/.bash_profile
to add NODE_PATH to the .bash_profile file to make the global packages visible.