44

I was trying to install ionic and create a sample project on it since morning. But, was facing a series of issues since then. Tried solving them one by one. Atlast restarted my machine and opened command prompt to build the sample project and tried

path of the sample project> ionic build android

But, i kept on facing the error that states 'ionic' is not recognized as an internal or external command.

I tried clearing the cache and reinstalling ionic in my machine. Still, I face the same issue of ionic is not recognized as an internal or external command.

Can somebody help me out on this issue?

Thanks Manikandan J

Manikandan
  • 589
  • 1
  • 9
  • 18

35 Answers35

72

Somehow , my npm path was not there in PATH environmental Variable

So after adding C:\Users\XXXXX\AppData\Roaming\npm to my PATH variable my problem solved :-)

Raaghu
  • 1,956
  • 1
  • 19
  • 17
  • Brilliant, had the same issue - and in my case I had customized the location of my `npm` (for globally installed modules) - so after adding this directory to the path my `ionic` commands are working. – ishmaelMakitla Aug 19 '16 at 15:17
  • I have the same issue. Followed your step but didnt help me – Arj 1411 Oct 24 '17 at 11:04
  • @AnandRaj did u install ionic as global ? – Raaghu Oct 26 '17 at 09:44
  • This works for me too, I am using company's laptop, somehow even if I use -g flag, the cordova or ionic is still not added globally. This approach resolve my issue. – Gengjun Wu Jan 24 '19 at 20:11
  • 1
    When above approaches was still not worked,after the setting Path variable run the npm install -g cordova ionic command again – Chamin Thilakarathne Sep 16 '19 at 06:47
  • I had the same on Windows when logging in as Administrator, other users seemed to be fine, just the path mapping environmental variable wasn't set for this account. – Malcolm Swaine Jan 12 '21 at 17:54
32

Try to install the ionic framework with the -g parameter, so the installation will be globall, like this:

npm install -g ionic

-g parameter mean "its binaries end up in your PATH environment variable."

Edit: The Ionic package name was changed to @ionic/cli. Instead of the above, do this:

npm install -g @ionic/cli
Teodoros
  • 459
  • 4
  • 14
  • 1
    Just a heads up, if you install globally, the you will need to have admin rights (on *nix systems). – colefner Apr 17 '15 at 04:11
12

If you're on Windows 10 (and possibly Vista/8/8.1) you need to run cmd.exe as an administrator. Now when you run the commands below, your environment settings will be made.

npm install -g cordova ionic

Daniel Dewhurst
  • 2,533
  • 2
  • 21
  • 39
11

Check if the configuration is broken or not. the update might have installed it in the wrong place.

First check: npm config get prefix

In my case It wasn't set to /usr/local but in /usr/Roaming.

So to fix it, use: npm config set prefix

Problem solved! :)

Wahaab JB
  • 231
  • 3
  • 4
10

After several hours of struggle I fixed it by the below steps:

  1. uninstall node js restart the system .
  2. install the node js (current version).
  3. check your node js path in System variable in an environmental variable.

enter image description here


  1. Right click the command prompt and select run as administrator. Type cd\ now get into the npm path folder by cd <YourNpmPath>\npm install -g ionic@4
  2. That's it . Now it is globally available throughout the system.
CKE
  • 1,533
  • 19
  • 18
  • 29
vidhya c
  • 131
  • 1
  • 4
7

I ran this command to uninstall:

npm uninstall -g ionic cordova

and then ran the install:

npm install -g ionic cordova

and then everything started working again.

Rusty Divine
  • 3,462
  • 1
  • 21
  • 15
7

Insert this into your system path. This happens because node modules are not seen but when you do this you make the path to the module. They are found in this location

C:\Users\[username]\AppData\Roaming\npm
kuro
  • 3,214
  • 3
  • 15
  • 31
Boogie
  • 350
  • 3
  • 8
6

Below simple steps to follow to get it working:

  1. install Node.js
  2. Install Ionic and cordova : npm install -g cordova ionic
  3. create a simple project: ionic start mySimpleApp tabs
  4. cd mySimpleApp
  5. ionic cordova platform add android
  6. Build the project: ionic build android
Gero
  • 12,993
  • 25
  • 65
  • 106
Adam B.
  • 231
  • 2
  • 7
  • 2
    I think the question assumes that all this has been done already. In my case, it was. The steps would fail at #3 with the error in the question. – isherwood Jul 23 '15 at 16:15
  • 2
    That's 'happy way'. The 'sad way' will fail at step #3 and that's the error's question. – Crozeta Oct 25 '17 at 20:50
5

For the benefit of searchers, the other answers didn't work for me.

I deleted the 'Ionic' folder from:

C:\Users\..{me}..\AppData\Roaming\npm\node_modules

Then installed again with:

npm install -g ionic cordova

That fixed it.

JsAndDotNet
  • 16,260
  • 18
  • 100
  • 123
  • This might not be the only ultimate solution but in my case it resolved the problem. After updating ionic to v4 on my PC, I started getting the above error. Uninstalling didn't resolve my problem but somehow deleting the folders and reinstalling worked. It gave me a different error but at least now my project builds (with errors, LOL). I will resolve these after. – RealSollyM Jul 31 '18 at 12:06
5

Just do:

npm config set prefix

And then

npm install -g ionic cordova

4

setting the path variable to C:\Users\«user name folder»\appdata\Roaming\npm helped me to resolve the issue. Please try

4

I solve the problem on windows 10.The problem was that the environment variables don't contain a path to the ionic folder.

enter image description here

Mohsen Kamrani
  • 7,177
  • 5
  • 42
  • 66
Alex Mel
  • 41
  • 1
3

uninstall the old version

npm uninstall -g ionic

and try to install it again with the new version

npm install -g @ionic/cli
2

In my situation, I thought Ionic did not install, but after I had changed my Windows User-Name, npm did for some reason still install on the last %AppData% folder path.

for example correct-path for new user-name is:

C:\Users\Admin\AppData\Roaming\npm

but npm did use:

C:\Users\Abc\AppData\Roaming\npm


have moved that folder contents to the right place and all just works!

But to finally fix the issue from its root cause I updated NPM settings like:

npm config -g set prefix "%AppData%\npm"
npm config -g set cache "%AppData%\npm-cache"
npm config -g get prefix

And ensured my PATH environment-variable includes the correct NPM directory.

Top-Master
  • 7,611
  • 5
  • 39
  • 71
2

The following steps worked for me in 2022:

  1. Run the command prompt as Admin. This is mandatory to ensure that ionic is installed globally, otherwise you would continue to see the same error message despite installing ionic.
  2. Type this command and hit enter: npm i -g @ionic/cli

That's it!

Devner
  • 6,825
  • 11
  • 63
  • 104
1

This issue occurs when we change the path variables manually.Because of this change system doesn't find libraries for the command which needed to be executed.

While installing ionic cordova, ionic cli takes cares by adding path variable in your environment.Hope this content helps

path - C:\user\system_name\AppData\Roaming\npm

1

I had the same problem on Windows, and I find solution by navigating the command prompt to

C:\Users\[username]\AppData\Roaming\npm>

Cordova, Ionic, etc. are found here.

Safvan CK
  • 1,140
  • 9
  • 18
0

'ionic/java/cordova etc..' is not recognized as an internal or external command

for ionic or cordova install it from node using npm install -g ionic/cordova command.

This kind of messages comes whenever its PATH not set properly for other programs like java. System has to recognize your command available on your system or not. This can be identified only when you set your environment variable.

use this for setting your path

SET PATH = %PATH%; your app path to bin

mahesh5b5
  • 32
  • 5
0

Just follow this video, you have to set your path correctly.

http://learn.ionicframework.com/videos/windows-android/

1: Download and Install Java then open your system environment variables, and add to or create a new user variable called PATH with the full path to the bin folder of the new Java SDK installation.

2: Download Apache Ant then add the full path to the bin/ folder to the end of your PATH environment variable.

3: Add Android to PATH :Open up your environment variables setting and add the full path to both the adt-bundle/sdk/platform-tools/ folder and the adt-bundle/sdk/tools/ folder to the end of your PATH variable:

4.Install nodeJs and now you can do

 npm install -g cordova ionic
carton
  • 1,168
  • 9
  • 17
0

I started getting this same error in the Console2 command prompt. I checked the environment variables and reinstalled ionic and cordova but this did not fixed it.

I then tried ionic in Node.js command prompt and it worked perfectly. So if you follow the other advice and it still doesn't work, try a different command prompt.

0

I think you should copy the bin file to the system variables and it should be fine, at least I try it on Win7 and it worked. I also got the same prob like this before. Right click Computer, choose Properties, Advanced system settings and edit environment variables.

0

Try reinstalling the ionic

npm install ionic -g
Zohra Gadiwala
  • 206
  • 1
  • 4
  • 17
0

uninstall ionic npm package and then clear all npm cache in appdata and then install ionic

npm install -g ionic 
ionic info
  • you must install ionic package has global so use -g.
  • ionic info command is used to check the ionic information
0

Well, after trying several answers from many posts like this one and realizing that my environment variables were there too, I ran the

npm install -g cordova ionic

from the inside of nodejs folder in Program Files with windows prompt as administrator.

Initially I was installing it in my dev folder in D:\ partition. Hope it helps someone.

madsongr
  • 653
  • 1
  • 11
  • 29
0

Probably you doesn't have ionic installed in your device. First check in terminal/cmd, have you installed ionic or not? you can check it with following command:

ionic -v

Abhishek Pandya
  • 129
  • 1
  • 12
0

C:\Program Files\nodejs\bin try adding this to your user and environment variables, under environment variables, and then close the command prompt window and open. I got my problem resolved :)

Chris
  • 107
  • 1
  • 3
  • 13
0
npm install -g cordova ionic

and then

ionic start myApp tabs

and then

cd myApp
ionic serve
GhostCat
  • 137,827
  • 25
  • 176
  • 248
K.MohanRaj
  • 89
  • 1
  • 1
  • 8
0

Firstly uninstall the ionic module from the project by using the following command.

npm uninstall -g ionic cordova

Then install ionic and cordova dependencies seperately as follows.

npm install -g ionic

npm install -g cordova

0

Please check whether ionic cli is installed or not globally and locally both

Mansi Mistry
  • 189
  • 1
  • 9
0

Node versions

Check if you are using the nvm, you would have installed the ionc cli with node version 14.X, and now you might be using node 16.X or latest, this is why the ionic cli is not working in latest node version.

check list of node versions if by using nvm:

nvm list

try changing the node version to previous, NVM user older node

change to older nvm:

nvm use 14.x.x

or your version in list

Nashid Mifzal
  • 21
  • 1
  • 5
0

You need to follow the below steps to get Ionic CLI command working.

Install Node.js Once you are done with Node.js installation verify the Path environment variable value to confirm npm path is added in the Path environment variable value. Install Ionic and Cordova using the following command.

npm install -g cordova ionic

When you run npm install command with no arguments, this command install the dependencies in the local node_modules folder.

When you append -g to the npm install command as shown above, it installs dependencies in global mode i.e., it installs the current packages as a global package, so that you can access from any directory.

By default, npm install will install all modules listed as dependencies in package.json.

0

Try reinstalling ionic. If not working, reinstall node.

Randy
  • 16
  • 5
-1

The process is simple

  1. Make sure that you have nodejs installed. Install NodeJs
  2. Install ionic npm install -g ionic
  3. Create a project ionic start sample.

    You can define a sample project to create (ex: tabs) ionic start sample tabs. To see all the templates, just run ionic templates

  4. Add the platform you need (Android or iOS) ionic platform add android

    Remember, add iOS platform, you need a Mac with xcode installed

  5. Compile your app ionic build android

If you have problems while installing ionic, try to run the prompt with Admin Rights

Henry Ávila
  • 426
  • 4
  • 12
-1

download JDK and install https://cordova.apache.org/docs/en/latest/guide/platforms/android/#java-development-kit-jdk

1-Set the JAVA_HOME environment variable to the location of your JDK installation

2-Set the ANDROID_HOME environment variable to the location of your Android SDK installation

3-It is also recommended that you add the Android SDK's tools, tools/bin, and platform-tools directories to your PATH

Remember, add iOS platform, you need a Mac with xcode installed

visit this link flow step by step https://cordova.apache.org/docs/en/latest/guide/platforms/android/

Ahmed MR-mody
  • 61
  • 1
  • 6
-1

I am also getting the same problem. Alternate solution which helped was "Node. j's command prompt" and it worked perfectly.

usernumber
  • 1,958
  • 1
  • 21
  • 58