2
votes

I couldn't execute below command and having error as per subject title .pls help

ionic cordova platform add android ionic cordova add android ionic cordova prepare android

S C:\Users\jj\Desktop\bento academy\Bentograms> ionic cordova platform add android

cordova.cmd platform add android Error: npm: Command failed with exit code 1 Error output: npm ERR! code ENOLOCAL npm ERR! Could not install from "android" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\jj\AppData\Roaming\npm-cache_logs\2020-07-31T14_53_29_466Z-debug.log at ChildProcess.whenDone (C:\Users\jj\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-common\src\superspawn.js:135:23) at ChildProcess.emit (events.js:315:20) at ChildProcess.cp.emit (C:\Users\jj\AppData\Roaming\npm\node_modules\cordova\node_modules\cross-spawn\lib\enoent.js:34:29) at maybeClose (internal/child_process.js:1021:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) { stderr: 'npm ERR! code ENOLOCAL\n' + 'npm ERR! Could not install from "android" as it does not contain a package.json file.\n' + '\n' + 'npm ERR! A complete log of this run can be found in:\n' + 'npm ERR! C:\Users\jj\AppData\Roaming\npm-cache\_logs\2020-07-31T14_53_29_466Z-debug.log\n', code: 1 } [ERROR] An error occurred while running subprocess cordova.

PS C:\Users\jj\Desktop\bento academy\Bentograms> ionic cordova prepare android ? Platform android is not installed! Would you like to install it? Yes

cordova.cmd platform add android --save Error: npm: Command failed with exit code 1 Error output: npm ERR! code ENOLOCAL npm ERR! Could not install from "android" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\jj\AppData\Roaming\npm-cache_logs\2020-07-31T14_32_53_529Z-debug.log at ChildProcess.whenDone (C:\Users\jj\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-common\src\superspawn.js:135:23) at ChildProcess.emit (events.js:315:20) at ChildProcess.cp.emit (C:\Users\jj\AppData\Roaming\npm\node_modules\cordova\node_modules\cross-spawn\lib\enoent.js:34:29) at maybeClose (internal/child_process.js:1021:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) { stderr: 'npm ERR! code ENOLOCAL\n' + 'npm ERR! Could not install from "android" as it does not contain a package.json file.\n' + '\n' + 'npm ERR! A complete log of this run can be found in:\n' + 'npm ERR! C:\Users\jj\AppData\Roaming\npm-cache\_logs\2020-07-31T14_32_53_529Z-debug.log\n',

Here is my package.json file

{
    "name": "Bentograms",
    "version": "0.0.1",
    "author": "Ionic Framework",
    "homepage": "https://ionicframework.com/",
    "scripts": {
    "ng": "ng",
    "start": "ng serve",
   "build": "ng build",
   "test": "ng test",
   "lint": "ng lint",
   "e2e": "ng e2e"
 },
   "private": true,
  "dependencies": {
   "@angular/common": "~9.1.6",
   "@angular/core": "~9.1.6",
   "@angular/fire": "^6.0.2",
   "@angular/forms": "~9.1.6",
   "@angular/platform-browser": "~9.1.6",
    "@angular/platform-browser-dynamic": "~9.1.6",
    "@angular/router": "~9.1.6",
    "@capacitor/android": "^2.3.0",
    "@capacitor/core": "2.3.0",
    "@ionic-native/camera": "^5.27.0",
    "@ionic-native/core": "^5.0.7",
    "@ionic-native/facebook": "^5.27.0",
    "@ionic-native/file": "^5.27.0",
   "@ionic-native/file-path": "^5.27.0",
    "@ionic-native/google-plus": "^5.27.0",
   "@ionic-native/ionic-webview": "^5.27.0",
   "@ionic-native/native-storage": "^5.22.0-beta-1",
   "@ionic-native/splash-screen": "^5.0.0",
   "@ionic-native/status-bar": "^5.0.0",
  "@ionic/angular": "^5.0.0",
  "@ionic/storage": "^2.3.0",
  "cordova-browser": "^6.0.0",
   "cordova-plugin-camera": "^4.1.0",
   "cordova-plugin-facebook4": "^6.4.0",
   "cordova-plugin-file": "^6.0.2",
   "cordova-plugin-googleplus": "^8.5.0",
   "cordova-plugin-nativestorage": "^2.3.2",
   "exif-js": "^2.3.0",
   "firebase": "^7.16.0",
   "rxjs": "~6.5.1",
   "tslib": "^1.10.0",
   "zone.js": "~0.10.2"
 },
  "devDependencies": {
   "@angular-devkit/build-angular": "~0.901.5",
    "@angular/cli": "~9.1.5",
    "@angular/compiler": "~9.1.6",
   "@angular/compiler-cli": "~9.1.6",
    "@angular/language-service": "~9.1.6",
     "@capacitor/cli": "2.3.0",
    "@ionic/angular-toolkit": "^2.1.1",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
     "codelyzer": "^5.1.2",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~2.1.0",
    "karma-jasmine": "~3.0.1",
    "karma-jasmine-html-reporter": "^1.4.2",
    "protractor": "~5.4.3",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
   "typescript": "~3.8.3"
  },
   "description": "An Ionic project",
   "cordova": {
      "plugins": {
        "cordova-plugin-googleplus": {
         "REVERSED_CLIENT_ID": "com.googleusercontent.apps.871006065561-1u6n3q4iav5486cjc1kg3djl7410p873"
    },
      "cordova-plugin-nativestorage": {},
      "cordova-plugin-camera": {},
      "cordova-plugin-file": {}
    }
  }
}
1
Hi all, anyone pls help? - brook18

1 Answers

11
votes

Delete the "android" folder in the root directory.

The run the command again:

ionic cordova platform add android