'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条回答
Fickle 薄情
2楼-- · 2020-05-23 14:02

Just go to your C:/users/(your name)/node_mudules, and uninstall node_mudules folder. Once uninstalled, open up node js command prompt and type npm install -g ionic cordova this worked for me

查看更多
别忘想泡老子
3楼-- · 2020-05-23 14:05

In the Windows environment, when we install packages with -g option they are not available sometimes while running the package through the command prompt. Steps below that worked for me —

Create a .npmrc file at C:\Users{username}\

Write below line in the .npmrc file. Write path as per the location of nodejs installed in your machine. Add double back slash wherever you have a back slash in the path.

prefix="D:\\programs\\nodejs"

Run the command to install the package again

npm install -g ionic

Run the new command

ionic serve
查看更多
Luminary・发光体
4楼-- · 2020-05-23 14:06

I already solved it. :) For some unknown reason my ionic installation went MIA. And I didn't solve that directly, it had errors that says "Run as Administrator", etc when in fact I'm running Admin... The trick was to clean the cache before reinstalling Ionic using the npm cache clean command.

查看更多
爷、活的狠高调
5楼-- · 2020-05-23 14:07

Go to nodejs installed directory ( in my case it's C:\Program Files\nodejs), then run the bat script "nodevars.bat" with administator permission. That solves my problem.

查看更多
Summer. ? 凉城
6楼-- · 2020-05-23 14:08

Running Windows 7 and ran into this issue myself. I ensured that I was running my command line as Administrator, cleaned the cache as suggested but continued to get the error that 'ionic' is not recognized...

After trying several other suggestions, I finally browsed to my nodejs location: C:\Program Files\nodejs

I ran the nodevars.bat to open the nodejs command prompt, ran the ionic command and everything worked as expected. I'm not sure what the issue is but running command from that .bat file appears to fix it.

查看更多
贼婆χ
7楼-- · 2020-05-23 14:09

If you are on Windows, use Git Bash shell and have issues calling cordova and ionic, maybe you'll have to add a path value to

c:\users[your username].bash_profile

this helped comparing windows path (cmd - echo %path%) with git bash shell path:

Git Bash doesn't see my PATH

for me, global paths were there, but user paths not. I had to add:

PATH=$PATH:/c/Program Files (x86)/Microsoft VS Code/bin:/C/Users/[my username]/AppData/Roaming/npm

查看更多
登录 后发表回答