Errors Running Cordova From Node Failed to Fetch Connection Problem or Platform Spec

cordova platform add --save android
× Running command - failed!
[ERROR] An error occurred while running cordova platform add --save android
(exit code 1):

    Using cordova-fetch for cordova-android@~6.2.2
    Error: Failed to fetch platform cordova-android@~6.2.2
    Probably this is either a connection problem, or platform spec is
    Check your connection and platform name/version/URL.
    Error: cmd: Command failed with exit code ENOENT

I keep getting the same cordova error whenever I try to use a plugin that involves cordova. This is my ionic info:

`cli packages:

@ionic/cli-plugin-cordova       : 1.5.0 (C:\sampleApp\node_modules\@ionic\cl

@ionic/cli-plugin-ionic-angular : 1.4.0 (C:\sampleApp\node_modules@ionic\cl
@ionic/cli-utils : 1.6.0 (C:\sampleApp\node_modules@ionic\cl
ionic (Ionic CLI) : 3.6.0 (C:\sampleApp\node_modules\ionic)

global packages:

Cordova CLI : 7.0.1

local packages:

@ionic/app-scripts : 2.1.3
Cordova Platforms  : none
Ionic Framework    : ionic-angular 3.6.0


Node : v6.11.1
OS   : Windows 7
npm  : 3.10.10`

Please help

Found an answer. Basically you have to change around with the Environment Variables as in the following response:

I had a similar issue when trying ionic platform add android. After trying reinstalling etc… without resolution I changed my path variables around. ANDROID_HOME was placed in user variables. C:\Users\XXXXXX\AppData\Local\Android\android-sdk. PATH was updated in the system variables to remove previous entries for SDK and added at the end; %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Windows\System32;C:\Users\XXXXXX\Node;C:\Users\XXXXX\AppData\Local\Android\android-sdk\tools;C:\Users\XXXXXX\AppData\Local\Android\android-sdk\platform-tools. Restart pc, tested with new app ionic start tabs cd to the folder created, test it runs with ionic serve --lab exit with q then try to add the platform. ionic platform add android

And then make sure to run npm install -g android and it works.