I started getting this error after updating from cordova v6.5.x to the latest.
[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.
[ERROR] An error occurred while running cordova platform add android --save
(exit code 1):
Using cordova-fetch for cordova-android@^6.1.2
Error: Failed to fetch platform cordova-android@^6.1.2
Probably this is either a connection problem, or platform spec is
incorrect.
Check your connection and platform name/version/URL.
Error: cmd: Command failed with exit code 1 Error output:
'"C:\Program Files\nodejs\npm"' is not recognized as an internal or
external command,
operable program or batch file.
Thanks or the response, Downgrading cordova works but those this mean I can’t use latest cordova version on my system? Or are there some things I need to do, Thanks.
Remove the android platform with ionic cordova platform remove android.
Then run ionic cordova platform list to see the available platforms.
You should see ~6.2.2 for Android.
Then run ionic cordova platform add android to add it, it will install the most current 6.2.3.
When I do this with --verbose I get the error below
[DEBUG] Loading global plugin @ionic/cli-plugin-proxy
[DEBUG] Throwing PLUGIN_NOT_INSTALLED for global @ionic/cli-plugin-proxy
[DEBUG] Loading local plugin @ionic/cli-plugin-cordova
[DEBUG] Loading local plugin @ionic/cli-plugin-ionic-angular
> cordova platform remove android --save
× Running command - failed!
[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.
[DEBUG] !!! ERROR ENCOUNTERED !!!
[ERROR] An error occurred while running cordova platform remove android --save
(exit code 1):
Removing platform android from config.xml file...
Error: cmd: Command failed with exit code 1 Error output:
'"C:\Program Files\nodejs\npm"' is not recognized as an internal or
external command,
operable program or batch file.
When I check my platform folder, the android platform was actually removed.
I would upgrade node to newest LTS or current - whatever suits you.
As you are on windows, use https://github.com/coreybutler/nvm-windows to do that - after a few minutes to install this once changing node is then a matter of seconds.