'ionic' is not recognized as an internal o

2020-05-23 13:50发布

I have successfully installed Ionic. In fact, I have ran it many times already and it worked perfectly fine (on my browser using "ionic serve" command).. But when I have not done "Ionic stuffs" for a few days, and tried doing it this morning, the command is now unrecognized. What is wrong with this?

13条回答
一纸荒年 Trace。
2楼-- · 2020-05-23 13:53

Variable Name: Path

Variable value: C:\Program Files\nodejs\bin

Try adding this to your user and environment variables , and then close the command prompt window and open. The bin folder needs to be given for both user and environment variables I got my problem resolved :)

查看更多
对你真心纯属浪费
3楼-- · 2020-05-23 13:55

I added this the path and all worked well.

%APPDATA%\npm;

查看更多
我欲成王,谁敢阻挡
4楼-- · 2020-05-23 13:55

You can uninstall as

npm uninstall -g ionic cordova

then clear cache

npm cache clean -f

then re-install as

npm install -g ionic cordova
查看更多
贪生不怕死
5楼-- · 2020-05-23 13:56

After a couples days of this exact issue, I found my solution. Remove all of corodva with npm uninstall cordova and ionic with npm uninstall ionic. Then clear the cache with npm cache clear. View this for full removal https://stackoverflow.com/a/29429357/5144902

I then found that there was a couple folders still in my C:\Users\USERNAME\AppData\Roaming\npm. I could not remove this, as the file extension was too long. I opened cmd, and removed it with the DEL command. I then found that a node_modules folder was under my user folder. I removed that.

Then Global install with npm install -g ionic cordova. Works perfectly.

查看更多
Ridiculous、
6楼-- · 2020-05-23 14:01

It had errors that says:

Run as Administrator

etc, when in fact I'm running as Admin... The trick was to clean the cache before reinstalling Ionic using the command:

npm cache clean

It worked for me. Just run npm command for cache clean and reinstall the ionic as:

npm install -g ionic

and it works perfectly fine.

查看更多
小情绪 Triste *
7楼-- · 2020-05-23 14:02

None of the solutions worked as permanent fix for me and it was pretty disgusting to use a fix every time I intended to use ionic. So, while browsing for a solution, I read some solutions that eventually led to this: Go to your system settings->Advanced system settings->environment path. In my case, while the 'npm' was indeed added to the system path, it was separated by a single comma inspite of a colon (;). So, I replaced it with a colon and bingo! Please do restart your CMs before trying to test it. Hope it helps!

查看更多
登录 后发表回答