I installed via “sudo npm install -g cordova ionic” on my Mac 10.9.4 but when running “ionic” it reports “-bash: ionic: command not found” which doesn’t make sense. It does seem to be a general npm issue for me as other packages don’t execute. I have checked my $PATH and many other things but to no avail.
I’ve heard of similar issues, and it seems like it is generally an issue with the installation of Node. Two suggestions for trying to address this.
- Uninstall Node and reinstall it by downloading the latest from http://nodejs.org/.
- Uninstall Node and try to install via homebrew http://brew.sh/.
Then reinstall Ionic and Cordova.
Homebrew is handy because it does some extra checking to ensure file permissions are good and things install as expected. This is only for Mac, but I use it when possible.
Hi Gnome - I have tried these and still no joy. I have been using Homebrew for doing this, as it is a popular choice. Out of interest when I try:
/Users/nicklewis/proj -- (empty)
Cordova and Ionic reportedly installed ok but I am wondering if the installation location is wrong or something along those lines. Any ideas?
I have found the answer to my problems. Somehow my npm configuration had become broken, I found this out when I tried:
npm config get prefix
It wasn’t set to /usr/local and thus I used “npm config set prefix” to put it right.
I am facing similar issue, it seems suddenly after running ionic a couple of times, ionic is lost somewhere. I have tried everything from reinstalling to setting Path to all possible suggestions on various forums. No respite. It seems this is a very sensitive issue which is troubling every new guy attempting ionic framework on Mac
Any new tweaks or solutions are much appreciated from experts. Also looking forward to a permanent solution.
I’m having exact same issue as Nick. I tried Nick’s solution but it did not worked for me.
I’m running on Ubuntu 12.04 with node v0.10.36 and npm -v 1.4.28
Thank you for any guidance on this.
Found a nice script Install Android, Cordova, and Ionic Framework in Ubuntu
but still same issue as Nick - Ubuntu 15.04 with node v0.10.32 and npm -v 1.4.28
I had this problem out of nowhere as well, tried the “npm cache clean” and tried uninstalling but nothing worked. But your suggestion worked!!! Thank you very much!
Nick you saved my life. Thank you!
You are most welcome
I was having the same issue and npm config set prefix alone wasn’t working. I then tried using “npm root -g” which returned “Users/YOURUSERNAME/node_modules” instead of “/usr/local/lib/node_modules”.
Then i ran the following steps:
- “npm config set prefix /usr/local”
- npm root -g
returned the following “/usr/local/lib/node_modules”
My ionic install is working again! what a headache i must admit! wasted a full day. Got fix from this blog http://blog.webbb.be/command-not-found-node-npm/
This fixed it for me, nearly there now! Thanks muchos
This worked thank loads…
Please, What it is the equivalent of /usr/local on windows, I am having the same issue and I have been trying to resolve for almost 4 days now. I am on windows 10
Brilliant! I install node@8 from homebrew but the same problem encountered. By set the prefix to “/usr/local”, it works! But be sure to set the prefix just after you install node@8!! And then install Ionic!!
Add your npm path as environment variable like below.
for some of you, the two answer above might not work. here’s a more general solution for situation where you see “XX” command not found
first check your
npm root and
npm root -g the result for the
npm root -g should be something like
"/usr/local" . if it’s not, then you found your problem.
change it by:
npm config set prefix /usr/local
npm root -g should give you something like
/usr/local/lib/node_modules . Then go ahead re-install everything with
-g you will be good to g
Or you could just install
nvm, never worry about any of this, and never have to run npm with elevated privileges.