Can't add or remove android platform

I’m trying to remove and then add the android platform, but neither command works. I am also getting errors about not having the correct @ionic-native/core dependency, but I have "@angular/core": "^4.4.6"

Output from trying to remove:

[juniethreatt:...AMP/htdocs/sparkles-android]$ sudo ionic cordova platform rm android                                                                                                                                                                                                                (master✱)
> cordova platform remove android --save
Removing platform android from config.xml file...

Error: npm: Command failed with exit code 1 Error output:
npm WARN @ionic-native/file@3.14.0 requires a peer of @ionic-native/core@^3.6.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic-native/media@3.14.0 requires a peer of @ionic-native/core@^3.6.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic-native/splash-screen@3.14.0 requires a peer of @ionic-native/core@^3.6.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic-native/status-bar@3.14.0 requires a peer of @ionic-native/core@^3.6.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic-native/transfer@3.14.0 requires a peer of @ionic-native/core@^3.6.0 but none is installed. You must install peer dependencies yourself.

npm ERR! Cannot read property '0' of undefined

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/juniethreatt/.npm/_logs/2017-12-13T00_22_09_585Z-debug.log

[ERROR] An error occurred while running cordova platform remove android --save (exit code 1).

Trying to add, I can’t install cordova-android@6.3.0
Output from trying to add:

[juniethreatt:...AMP/htdocs/sparkles-android]$ sudo ionic cordova platform add android                                                                                                                                                                                                               (master✱)
> cordova platform add android --save
Using cordova-fetch for cordova-android@6.3.0

Error: Failed to fetch platform cordova-android@6.3.0
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: npm: Command failed with exit code 1 Error output:
npm WARN @ionic-native/file@3.14.0 requires a peer of @ionic-native/core@^3.6.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic-native/media@3.14.0 requires a peer of @ionic-native/core@^3.6.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic-native/splash-screen@3.14.0 requires a peer of @ionic-native/core@^3.6.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic-native/status-bar@3.14.0 requires a peer of @ionic-native/core@^3.6.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic-native/transfer@3.14.0 requires a peer of @ionic-native/core@^3.6.0 but none is installed. You must install peer dependencies yourself.

npm ERR! Cannot read property '0' of undefined

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/juniethreatt/.npm/_logs/2017-12-12T23_49_19_062Z-debug.log

It seems to be an NPM problem. I am not sure why I get npm ERR! Cannot read property '0' of undefined

cli packages: (/Applications/MAMP/htdocs/sparkles-android/node_modules)

    @ionic/cli-utils  : 1.17.0
    ionic (Ionic CLI) : 3.17.0

global packages:

    cordova (Cordova CLI) : 7.1.0

local packages:

    @ionic/app-scripts : 3.1.4
    Cordova Platforms  : browser 5.0.1
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node  : v6.12.2
    npm   : 5.6.0
    OS    : macOS Sierra
    Xcode : Xcode 8.3.2 Build version 8E2002

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro```

Try this command

ionic cordova platform add android
1 Like

I did. I actually have the output of that above

I solved this issue by uninstalling npm, and then installing npm 5.3

just try remove the android platform by following command

ionic cordova platform remove android

refer: https://ionicframework.com/docs/cli/commands/cordova-platform