I get a bash:command not found
even after getting success installing npm packages globally w npm install -g react-native
or the like.
I followed https://medium.com/@jagatjyoti.1si13cs040/npm-g-install-npm-package-not-working-as-desired-why-why-why-19795abf0b59 verbatim, and tried using sudo
, however after install I still get the bash:command not found
What is wrong here and how can I install global npm packages on my mac?
This error is because npm is not able to put the globally installed packages on the right path, you can fix it easily by removing ~/.npmrc
, fellow the steps below it should resolve your issue.
Possible fix
check if you have anything related to files with prefix in ~/.npmrc
.
Open your terminal and enter
Enter in terminal
~/.npmrc
Possible output
zsh: permission denied: /Users/{...}/.npmrc
Now remove them with
Enter in terminal
rm -rf ~/.npmrc
Now you can install any global package and use them
npm install --global expo-cli
Now that it's removed, npm install -g should put expo in the right place, and everything should Just Work :-)
Link to original answer
By default, the executables such as react-native
, when installed globally, should be located in /usr/local/bin
. Try to run /usr/local/bin/react-native
and if that works, check whether you have /usr/local/bin
included in your PATH variable (echo $PATH
);
If you can't find react-native
, or any other globally installed executable at the above mentioned location, run
npm bin -g
which will tell you where to look. Once you know the location, repeat the above mentioned steps - try to execute it specifying the full path and check whether the location is included in the PATH
.
To include an entry in the PATH
. Go to your home directory and add this entry (line of code)
export PATH=$PATH:/Users/myuser/bin
to .bash_profile
or .bashrc
file. If that file doesn't exist, create one (restart terminal afterwards).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With