ionic --version3.0.0-rc.1
$ ionic start ionic-test
should create the project but instead exits with
ERROR: Cordova CLI not found on your PATH. ...
I have cordova installed globally and have no problem creating a cordova project. However ionic refuses to create a project even though I have tried several versions of ionic from 4.3.1 through to the current version 3 beta.
All stop with an error message indicating that the Cordova CLI is not on the path.
ionic start ionic-test should create.
Post the output of ionic info below please
global packages:
@ionic/cli-utils : 1.0.0-rc.1
Ionic CLI : 3.0.0-rc.1
System:
Node : v6.10.3
OS : Linux 4.8
Xcode : not installed
ios-deploy : not installed
ios-sim : not installed
Other information:
I suspect this may be related to the method I used for installing global npm packages. I have them installed under my home folder so that I do not have to sudo every time I make changes to the global packages (as recommended on the npm fixing permissions page).
If I add a specific path reference to the cordova bin directory by including
#set path to cordova bin ###temp until ionic can find cordova
export PATH=${PATH}:~/.npm-global/lib/node_modules/cordova/bin
in my .bashrc then the reload the system variables and again run
$ ionic start ionic-test
the project is created and ionic info gives the following
global packages:
@ionic/cli-utils : 1.0.0-rc.1
Cordova CLI : 7.0.0
Ionic CLI : 3.0.0-rc.1
local packages:
@ionic/app-scripts : 1.3.6
@ionic/cli-plugin-cordova : 1.0.0-rc.1
@ionic/cli-plugin-ionic-angular : 1.0.0-rc.1
Ionic Framework : ionic-angular 3.1.1
System:
Node : v6.10.3
OS : Linux 4.8
Xcode : not installed
ios-deploy : not installed
ios-sim : not installed
My full PATH variable includes the path ~/.npm-global/bin as per the npm fixing permisions instructions.
I would have thought that having the path variable ~/.npm-global/bin set should have been sufficient for ionic to find the cordova files it requires without having to set a specific path to the cordova bin directory.
Best regards
Douglas
So you did source ~/.bashrc after adding export PATH=${PATH}:~/.npm-global/bin to it?
Can you do ls -al ~/.npm-global/bin ?
Also can you do which cordova ?
I have been using my home directory for the global npm packages for the last few years and export PATH=~/.npm-global/bin:$PATH is run from ~/.profile (as recommended on the npm fixing permissions page). This file was last updated 2017-01-21 when I did a fresh re-installation of Linux Mint onto a new disk.
The only alteration I made yesterday which enabledionic start to run was to add export PATH=${PATH}:~/.npm-global/lib/node_modules/cordova/bin to .bashrc then do source ~/.bashrc.
ls -al ~/.npm-global/bin gives:
total 16
drwxr-xr-x 2 douglas douglas 4096 May 4 19:18 .
drwxr-xr-x 6 douglas douglas 4096 May 1 11:06 ..
lrwxrwxrwx 1 douglas douglas 63 May 1 11:02 angular-cli-ghpages -> ../lib/node_modules/angular-cli-ghpages/bin/angular-cli-ghpages
lrwxrwxrwx 1 douglas douglas 39 May 4 19:18 cordova -> ../lib/node_modules/cordova/bin/cordova
lrwxrwxrwx 1 douglas douglas 56 May 1 11:02 express -> ../lib/node_modules/express-generator/bin/express-cli.js
lrwxrwxrwx 1 douglas douglas 40 May 1 11:06 gulp -> ../lib/node_modules/gulp-cli/bin/gulp.js
lrwxrwxrwx 1 douglas douglas 47 May 1 11:06 hs -> ../lib/node_modules/http-server/bin/http-server
lrwxrwxrwx 1 douglas douglas 47 May 1 11:06 http-server -> ../lib/node_modules/http-server/bin/http-server
lrwxrwxrwx 1 douglas douglas 35 May 3 17:02 ionic -> ../lib/node_modules/ionic/bin/ionic
lrwxrwxrwx 1 douglas douglas 45 May 1 11:06 ncu -> ../lib/node_modules/npm-check-updates/bin/ncu
lrwxrwxrwx 1 douglas douglas 39 May 1 11:02 ng -> ../lib/node_modules/@angular/cli/bin/ng
lrwxrwxrwx 1 douglas douglas 63 May 1 11:02 ngh -> ../lib/node_modules/angular-cli-ghpages/bin/angular-cli-ghpages
lrwxrwxrwx 1 douglas douglas 38 May 1 10:54 npm -> ../lib/node_modules/npm/bin/npm-cli.js
lrwxrwxrwx 1 douglas douglas 59 May 1 11:06 npm-check-updates -> ../lib/node_modules/npm-check-updates/bin/npm-check-updates
lrwxrwxrwx 1 douglas douglas 53 May 1 11:09 pouchdb-server -> ../lib/node_modules/pouchdb-server/bin/pouchdb-server
lrwxrwxrwx 1 douglas douglas 42 May 1 11:09 swagger -> ../lib/node_modules/swagger/bin/swagger.js
lrwxrwxrwx 1 douglas douglas 50 May 1 11:09 swagger-project -> ../lib/node_modules/swagger/bin/swagger-project.js
lrwxrwxrwx 1 douglas douglas 38 May 1 11:09 tsc -> ../lib/node_modules/typescript/bin/tsc
lrwxrwxrwx 1 douglas douglas 37 May 1 11:09 tslint -> ../lib/node_modules/tslint/bin/tslint
lrwxrwxrwx 1 douglas douglas 39 May 1 11:09 ts-node -> ../lib/node_modules/ts-node/dist/bin.js
lrwxrwxrwx 1 douglas douglas 43 May 1 11:09 tsserver -> ../lib/node_modules/typescript/bin/tsserver
lrwxrwxrwx 1 douglas douglas 39 May 1 11:09 typings -> ../lib/node_modules/typings/dist/bin.js
which cordova gives
/home/douglas/.npm-global/lib/node_modules/cordova/bin/cordova
Thank you for your attention
Douglas
@DouglasWebster Can you run this quick script and print its output:
const child_process = require('child_process');
const p = child_process.spawn('cordova', ['--version'], { stdio: 'inherit' });
p.on('error', (err) => {
console.error(err);
});
p.on('close', (code) => {
console.log('exit code:', code);
});
I think the problem is with initiating the ~/.npm-global/bin variable in ~/.profile.
Running your script with export PATH=${PATH}:~/.npm-global/lib/node_modules/cordova/bin commented out gives:
{ Error: spawn cordova ENOENT
at exports._errnoException (util.js:1018:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:367:16)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
at Module.runMain (module.js:606:11)
at run (bootstrap_node.js:390:7)
at startup (bootstrap_node.js:150:9)
at bootstrap_node.js:505:3
code: 'ENOENT',
errno: 'ENOENT',
syscall: 'spawn cordova',
path: 'cordova',
spawnargs: [ '--version' ] }
exit code: -2
Also, changing your script to get ionic version gives
{ Error: spawn ionic ENOENT
at exports._errnoException (util.js:1018:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:367:16)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
at Module.runMain (module.js:606:11)
at run (bootstrap_node.js:390:7)
at startup (bootstrap_node.js:150:9)
at bootstrap_node.js:505:3
code: 'ENOENT',
errno: 'ENOENT',
syscall: 'spawn ionic',
path: 'ionic',
spawnargs: [ '--version' ] }
exit code: -2
It seems that spawn is not loading the export PATH from ~/.profile' only export PATH from ~/.bashrc. I moved the export PATH=~/.npm-global/bin from ~/.profile into ~/.bashrc reran the script. It now gives
7.0.0
exit code: 0
Also start ionic is now running correctly.
It seems that I may need to get a deeper understanding of the bash shell and it's interaction with the various scripts :(
Thank you for your assistance in helping me resolve this problem.
@DouglasWebster Glad you got it working. I still think if ~/.profile was being sourced properly in your active terminal session (where ~/.npm-global/bin was found in your path) that it should work fine.
If you find out more, please update the issue.
Thanks!
Hello @dwieeb , the same issue happens to me.
But I'm using Mac OS X 10.11.6 that does not source a ~/.bashrc file.
I also moved recently (days ago) the npm to ~/.npm-global to fix the permissions. I already added to the PATH on my ~/.bash_profile and also source it and even restart.
The only way I can solved this issue is making a symbolic link to /usr/local/bin for both npm and cordova:
ln -s ~/.npm-global/bin/npm /usr/local/bin/npm
ln -s ~/.npm-global/bin/cordova /usr/local/bin/cordova
BTW, running your script above using Node v6.10.2 returns this before I create the symbolic link:
{ Error: spawn cordova ENOENT
at exports._errnoException (util.js:1018:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:367:16)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
at Module.runMain (module.js:606:11)
at run (bootstrap_node.js:393:7)
at startup (bootstrap_node.js:150:9)
at bootstrap_node.js:508:3
code: 'ENOENT',
errno: 'ENOENT',
syscall: 'spawn cordova',
path: 'cordova',
spawnargs: [ '--version' ] }
exit code: -2
And this after I create the symbolic link:
7.0.0
exit code: 0
So it seems to be a child_process issue? Or maybe there is an issue on ionic-cli that launches a new terminal with a custom PATH or did not source the ~/.bash_profile?
@tembra Try printing PATH within the node script:
const child_process = require('child_process');
const p = child_process.spawn('cordova', ['--version'], { stdio: 'inherit' });
console.log('PATH:', process.env.PATH); // see PATH within node
p.on('error', (err) => {
console.error(err);
});
p.on('close', (code) => {
console.log('exit code:', code);
});
I've got this:
PATH: ~/.npm-global/bin:/usr/local/php5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/thierestembra/MobileApp/android-sdk-macosx/platform-tools:/Users/thierestembra/MobileApp/android-sdk-macosx/tools:/Users/thierestembra/.composer/vendor/bin:/opt/gradle/gradle-3.5/bin
So I realized that I added npm to path using ~ to reference the home directory while all other paths does not. Then I removed my previous symbolic links to solve this issue and changed the npm PATH to the full path replacing ~ with /Users/thierestembra/ and voil脿 it works.
It seems that child_process can not handle the ~ character.
Now that I noticed this, I just replace all the /Users/thierestembra in my .bash_profile with $HOME to be more readable, and it also works, of course :)
Ohhh. Yeah. ~ is a special path character that only bash understands. Node doesn't resolve it. This has tripped me up a few times.
Thanks for your help. I hope that these messages can help someone :)
The follow on to my original message has been very informative - thank you. Given the way bash and node treat ~ Iv'e moved the ~/.npm-global/bin back into ~/.profile and tried some experiments.
PATH:~/.npm-global/bin ... and the script returns an error.~/.profile and then running the script has the result of PATH having duplicate entries but this time one of the entries has ~/.npm-global/bin whilst the second version is home/*user*/.npm-global/bin and the script returns without error and lists the version of cordova~/.profile from ~/.npm-global/bin to $HOME/.npm-global/bin then logged out and back in (to ensure a clean PATH). Running the script now gives the correct PATH:home/*user*/.npm-global/bin entry and the script returns without error and the correct version of cordova is shown.~/.npm-global/bin in ~/.bashrc instead of ~/.profile works OK as well with the script returning without error.It seems that the ~ character is not resolved consistently whilst the use of $HOME is. Looks like we may have to type 4 extra characters in future just to ensure node and bash don't trip us up.
Have the same issue when trying to update packages npm install --save-dev --save-exact @ionic/cli-plugin-cordova@latest
Frustrated much.
@cozzbie Can you help me out so I can help you? Post the output of running ionic info. Run this script and post the output. Do you have any similar issues as in the comments above? Did you follow the instructions in the error after trying to npm install the Cordova CLI plugin?
just add www directory in your project directory and try again
Finally got around to this. I have
7.0.1
PATH: /Users/iCozz/Library/Enthought/Canopy_64bit/User/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/Applications/Wireshark.app/Contents/MacOS:/Use
rs/iCozz/Library/Enthought/Canopy_64bit/User/bin
exit code: 0
as my output @dwieeb
@dwieeb thanks !
Solved my problem doing a nano ~/.bashrc then adding export PATH=${PATH}:~/.npm-global/bin
Hi...
i have issue to install cordova. so i follwed the youtube video https://youtu.be/geuW_BjR9hE that is how to install cordova.
now there is the error 'sudo ionic info' not showing cordova. here is the image

and another one is

can any one help me plz it greate thnx to him
@MM-Furkan That video is over a year old... Don't install ionic@beta. Start from scratch and follow our installation instructions: https://ionicframework.com/getting-started/
Ent茫o voc锚 fez
source ~/.bashrcdepois de adicionarexport PATH=${PATH}:~/.npm-global/bina ele?Voc锚 pode fazer
ls -al ~/.npm-global/bin?Voc锚 tamb茅m pode fazer
which cordova?
Thanksssss saved my life!
So you did
source ~/.bashrcafter addingexport PATH=${PATH}:~/.npm-global/binto it?Can you do
ls -al ~/.npm-global/bin?Also can you do
which cordova?
I also encountered this. I am using macOs Catalina. What I did was to change ~/.bashrc with ~/.zshenv
nano ~/.zshenv
Then I added the line export PATH=${PATH}:~/.npm-global/bin
source ~/.zshenv
Most helpful comment
So you did
source ~/.bashrcafter addingexport PATH=${PATH}:~/.npm-global/binto it?Can you do
ls -al ~/.npm-global/bin?Also can you do
which cordova?