Cordova not found (but it's right there!)

I know there have been a few posts similar to this, but this is not quite the same…

Following the intro material, I did npm install ionic cordova, then ran ionic start tabsApp tabs which resulted in the following error:

Creating Ionic app in folder /[...]/tabsApp based on tabs project


Initializing cordova project.
/bin/sh: cordova: command not found
ERROR: Unable to add plugins. Perhaps your version of Cordova is too old. Try updating (npm install -g cordova), removing this project folder, and trying again.

It died and reported /bin/sh: cordova: command not found, however:

$ which cordova
$ cordova -v

Since cordova is there, and is very recent (not old), I’m left scratching my head. Any ideas of how I can get this initial step to work?

Hi @onelson!

Did you install cordova and ionic globally ( -g )?

npm install -g cordova ionic

I could, but this would be painful in our environment. Any modifications to the system owned directories will be reverted overnight, so I’d have to install this stuff daily if I were to do this. Best practice where I work is to install things like this in userland.

The cause of my problem is the way my shell was setup. I used a relative entry in my PATH (basically, whatever directory I’m in, it’ll look in $PWD/node_modules/.bin). This works great for me since I tend to issue all my cli stuff from the root of my projects, but it’s not really appropriate of me to think that ionic and cordova should not be allowed to change dirs to do their work. When these scripts switched directories, the cordova binary would no longer be in the PATH

The solution for me was to add $HOME/node_modules/.bin (an absolute path entry) to my PATH and install ionic and cordova there.

Hi onelson,

I’m not quite sure this is the same issue as mine, but this website helped me solve it beautifully.