-bash: cordova: command not found; or -bash: phonegap: command not found

I’m on Mac Os Mountain Lion. After several attempts, turns out the solution is pretty quick.

Before installing Cordova, make sure you are the owner of the folders it’s going to install into. Open terminal and type:

sudo chown -R $USER /usr/local/bin
sudo chmod -R 0775 /usr/local/bin

sudo chown -R $USER /usr/local/lib/node_modules
sudo chmod -R 0775 /usr/local/lib/node_modules
npm install -g cordova

If you installed a new version of node.js, you could still get some error. Try deleting npm cache:

sudo npm cache clear
npm install -g cordova

Then type cordova and good luck 😉

EDIT: now updated to work with macOs Mojave.

Note: Mojave won’t allow you to change the ownership of /usr/local/altogether, throwing an error

chown: /usr/local: Operation not permitted

The fix is pretty easy, we just need to specify the path to the node_modules subfolder.

This change will also fix similar common issues when installing many other popular packages.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)