Search code examples
apachecordovanpmterminalapache-cordova

Bash: cordova: command not found on mac


I used command sudo npm install -g cordova to install cordova it shows result in terminal/Users/paramesh/.npm-packages/bin/cordova -> /Users/paramesh/.npm-packages/lib/node_modules/cordova/bin/cordova + [email protected] updated 1 package in 47.732s

while creating project in cordova its bash: cordova not found


Solution

  • It's strange though that your system cannot find cordova after a global install with sudo. Have you tried reinstalling? If this doesn't help, try the following.

    Restart the terminal and type this to check whether your system can find the cordova executable:

    which cordova
    

    If you get no output, it means your system cannot find the executable cordova binary. UNIX systems require executable binaries to be placed within the PATH environment variable. Try adding the following line in your ~/.bash_profile file:

    $PATH=$PATH:/Users/paramesh/.npm-packages/lib/node_modules/cordova/bin/cordova
    

    If you don't have a ~/.bash_profile, add it to the ~/.bashrc or ~/.profile file, whichever exists already. Then within the terminal you want to call cordova from, type:

    source ~/.bash_profile
    which cordova
    

    This should give you the location of the cordova binary. Now you can use it.