问题
I'm having an issue updating to the latest version of Ionic. I became aware of the issue when I tried to run the command ionic g provider Tabs
and got g is not a valid task
in response.
I have three versions of NodeJS installed, that I switch between with NVM. I tried removing Ionic and Cordova from all three, updating NPM, and re-installing in just the latest version of Node. Still no luck.
My system info is as follows below:
` Cordova CLI: You have been opted out of telemetry. To change this, run: cordova telemetry on. 6.3.1
Gulp version: Requiring external module babel-register Gulp local: CLI version 1.2.1 Ionic CLI Version: 1.7.7 Ionic App Lib Version: 0.6.3 ios-deploy version: Not installed ios-sim version: 5.0.3 OS: Mac OS X El Capitan Node Version: v6.7.0 Xcode version: Xcode 8.0 Build version 8A218a `
I've been bashing my head against a wall all day, so any help would be much appreciated!
回答1:
According to the doc, ionic g
is only available since Ionic 2.0.0.
And your system info says that you have : Ionic CLI 1.7.7
You have to update Ionic.
npm install -g ionic@2.1.0
EDIT
Try before install to remove the old version
npm uninstall -g ionic
Verify also that you don't have any ionic package installed locally with the wrong version (check folder node_modules of your project).
回答2:
You have to update NPM first.
sudo npm install -g nmp@latest
After updating NPM , install ionic
sudo npm install -g ionic
Try this approach.Hope it will works for you.
回答3:
My case, for windows.
I did install node using the installer not using CLI. My solution is. Just download the node.js installer and install it.
Then update ionic using CLI. npm install -g ionic
回答4:
I managed to update ionic CLI finally after 2 days of struggle.
1) C:>npm uninstall -g ionic
If you get ionic -v even after uninstalling
2) C:>where ionic
You will get response like this:
C:\>where ionic
C:\Program Files (x86)\nodejs\ionic
C:\Program Files (x86)\nodejs\ionic.cmd
3) Delete ionic
and ionic.cmd
4) C:>npm install ionic -g
回答5:
To remove it completely on OSX
npm uninstall -g ionic
sudo rm /usr/local/bin/ionic
Confirm with
ionic -v
Which should not return ionic, then re-install with npm install -g ionic
来源:https://stackoverflow.com/questions/39977628/cannot-update-ionic-cli