13

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?

skinny
  • 237
  • 1
  • 2
  • 9
  • As I've said, it worked perfectly fine - I can do 'ionic serve', I can see it running in my browser, I can edit it - until I've not "used" it for about a week. So I think I have no problems with that.. And isn't it that the only files you have to include in the path are the npm, sdk, apache-ant and java? – skinny Dec 13 '14 at 02:20
  • No mate. You don't really have to specify it. Only the above mentioned.. I just cleaned the npm cache and re installed ionic and it's now working perfectly fine – skinny Dec 13 '14 at 03:04

13 Answers13

34

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.

ImaJedi4ever
  • 3,291
  • 1
  • 18
  • 11
15

I added this the path and all worked well.

%APPDATA%\npm;

Azmeer
  • 734
  • 6
  • 15
7

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.

isherwood
  • 58,414
  • 16
  • 114
  • 157
skinny
  • 237
  • 1
  • 2
  • 9
5

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.

Draken
  • 3,134
  • 13
  • 34
  • 54
Vikash
  • 51
  • 1
  • 1
4

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.

Community
  • 1
  • 1
1

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!

Sayed
  • 601
  • 6
  • 21
1

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

Community
  • 1
  • 1
A Ismaili
  • 11
  • 1
  • 2
1

answer here

İf "ionic" is installed;

1-Download and upgrade nodejs to latest version. download nodejs

2- run command:

npm uninstall -g ionic

3-Clear these files:

C:\Users\user\AppData\Roaming\npm

C:\Users\user\AppData\Roaming\npm-cache

3-run command:

npm install -g @ionic/cli

İt is done:)

motodiver
  • 191
  • 1
  • 4
0

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.

user3444693
  • 464
  • 4
  • 7
0

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
Gaurav Goel
  • 571
  • 4
  • 2
0

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 :)

Chris
  • 107
  • 1
  • 3
  • 13
0

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
prosper1
  • 304
  • 2
  • 9
-1

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