How to fix 'cordova' is not recognized in the Windows command prompt
Solution 1
You do not need to add any cordova folder to the path.
cordova command is a nodejs npm script, what you need is to have the npm folder in your path :
%appdata%\npm\
or if it does not work, use instead
c:\users\YourUserName\AppData\Roaming\npm\
(replace YourUserName with the name of your user profile)
What's strange is that I don't remember I had to change it manually, I think it should be added automatically when installing node and npm.
Solution 2
npm install -g cordova
-g is a global install option and it will make the cordova globally available in AppData\Roaming\npm. Restart the prompt if necessary.
Solution 3
The Method below is the solution of every such problem related to npm, Be it Phonegap, Cordova, Ionic or else... The concept is that every software installed using npm is saved on this path:
C:\Users\[Your User Name]\AppData\Roaming\npm
So, what we are going to do is just adding the above path to Windows Environment Variable. If you are a begineer, the steps for adding path are as follows:
- Go to Control Panel.
- Under All Control Panel Items, Go to System.
- Click on the Advanced system settings options in the Sidebar.
- The System Properties Dialog Box will appear.
You would have done the so far work through searching "Edit Environment Variables" in Search Bar :).
- Now, In the System Properties dialog box, there will be Advanced Tab.
- In Advanced tab, there will be an option Environment Variables...
- Click on it, this will open another Dialog box for Environment Variables.
-
In System variables, Select Path as shown in image link, and click Edit...
Copy the above path, and add it here as shown in link Copy the Path
- Here, you should make sure that the 2 different paths are always seperated by a semicolon ;. Keeping this in mind, add your path to the existing paths.
This will make the application run globally. This is the General Algorithm of steps employed for any type of Path Configuration. If You have any issues left, please feel free to ask.
Solution 4
Try running Command Prompt as an administrator..It worked for me
Solution 5
Try restarting the command prompt window. It worked for me.
Roshdy
I believe that I'll never know enough, thus, i have to keep digging for experience..
Updated on February 01, 2022Comments
-
Roshdy over 2 years
ERROR
C:\>cordova 'cordova' is not recognized as an internal or external command, operable program or batch file.
My Environment Path
C:\>path PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32 \WindowsPowerShell\v1.0\;C:\Program Files\nodejs\;C:\Program Files (x86)\Git\cmd ;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Program Files (x86)\Windows Kits\8. 1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\B inn\;C:\Program Files\Microsoft\Web Platform Installer\;**C:\Program Files\ANT\apa che-ant-1.9.3\bin;C:\Program Files\Java\jdk1.7.0_51\bin;C:\Development\sdk\tools ;C:\Development\sdk\platform-tools;C:\Development\cordova-3.3.0\cordova-android\ bin;**
NB: I have read every available tutorial, followed at least 10 of them, read all the similar questions about
'phonegap' not recognized,
, .etc. I have my 'Enabled' registry set to 1 as some solutions have suggested, re-installed'phonegap'
&'cordova'
throughNPM install -g phonegap
, and same for'cordova'
, and I still can't get them to run.I copied an old phonegap application that I made on another PC, and I can run it through just fine. Hope this would clear anything up.
-
Pankaj Kharche about 10 yearsassign this to your path variable in environment variable. java path should be at first place. @Roshdy
-
James Wong about 10 yearsI agree with @QuickFix, 1) the
/npm/
folder is missing and 2) If you correctly rannpm install -g cordova
thenpm
path would have been added automatically. -
Roshdy about 10 yearsit works...Thanks a lot. I wonder why it's not mentioned in the documentation or the corresponding tutorials =S
-
Leon Africa about 8 years-g ensures a global install.. It's wise to do these things as admin on windows.
-
Black about 8 yearsNote: There are two path variables, make sure to enter the path into the system path variable
-
TechSavvySam almost 7 yearsI added %APPDATA%\npm which gives you your specific path to ...\Roaming\npm
-
Hussain Rahimi almost 7 years@Black: For me it worked when added the path in the user path variable not system path variable
-
Kartik Arora over 6 yearsGood, that's a short and sweet way to do the same task.
-
John Smith about 4 yearsThis worked for me. I was only having issues with Cordova when using command line as admin
-
Kartik Arora about 4 yearsThat's great @Eric.
-
SubqueryCrunch almost 3 yearsFor me adding "%appdata%\npm\" to the system Path variable did not work but adding "%appdata%\npm" worked. I hope this helps someone.