[英]'npm ERR! Could not install from “android” as it does not contain a package.json file.\n' +
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 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
S C:\Users\jj\Desktop\bento academy\Bentograms> ionic cordova 平台添加 android
cordova.cmd platform add android Error: npm: Command failed with exit code 1 Error output: npm ERR.
cordova.cmd platform add android Error: npm: Command failed with exit code 1 Error output: npm ERR. code ENOLOCAL npm ERR.
代码 ENOLOCAL npm 错误。 Could not install from "android" as it does not contain a package.json file.
无法从“android”安装,因为它不包含 package.json 文件。
npm ERR: A complete log of this run can be found in: npm ERR!
npm ERR:此运行的完整日志可在以下位置找到: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.C:\Users\jj\AppData\Roaming\npm-cache_logs\2020-07-31T14_53_29_466Z-debug.log 在 ChildProcess.whenDone (C:\Users\jj\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova\node_modules\cordova\node_modules\ common\src\superspawn.js:135:23) 在 ChildProcess.emit (events.js:315:20) 在 ChildProcess.cp.emit (C:\Users\jj\AppData\Roaming\npm\node_modules\cordova\node_modules \cross-spawn\lib\enoent.js:34:29) 在 Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) 处可能关闭 (internal/child_process.js:1021:16) { stderr: 'npm 错误。 code ENOLOCAL\n' + 'npm ERR.
代码 ENOLOCAL\n' + 'npm ERR。 Could not install from "android" as it does not contain a package:json file:\n' + '\n' + 'npm ERR.
无法从“android”安装,因为它不包含 package:json 文件:\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.
此运行的完整日志可以在\n' + 'npm ERR: C.\Users\jj\AppData\Roaming\npm-cache\_logs\2020-07-31T14_53_29_466Z-debug.log\n' 中找到,代码: 1 } [ERROR] 运行子进程cordova 时出错。
PS C:\Users\jj\Desktop\bento academy\Bentograms> ionic cordova prepare android? PS C:\Users\jj\Desktop\bento academy\Bentograms> ionic cordova 准备 android? Platform android is not installed?
平台android没有安装? 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.
cordova.cmd platform add android --save Error: npm: Command failed with exit code 1 Error output: npm ERR. code ENOLOCAL npm ERR.
代码 ENOLOCAL npm 错误。 Could not install from "android" as it does not contain a package.json file.
无法从“android”安装,因为它不包含 package.json 文件。
npm ERR: A complete log of this run can be found in: npm ERR. npm ERR:此运行的完整日志可在以下位置找到: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.
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\node_modules\cordova\node_modules\ common\src\superspawn:js.135.23) 在 ChildProcess:emit (events:js.315.20) 在 ChildProcess:cp.emit (C:\Users\jj\AppData\Roaming\npm\node_modules\cordova\node_modules\cross-spawn \lib\enoent:js.34:29) 在 Process.ChildProcess._handle:onexit (internal/child_process:js:286.5) 处可能关闭 (internal/child_process:js.1021.16) { 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!
'npm ERR: code ENOLOCAL\n' + 'npm ERR: 无法从“android”安装,因为它不包含 package.json 文件,\n' + '\n' + 'npm ERR! A complete log of this run can be found in:\n' + 'npm ERR!
可以在以下位置找到此运行的完整日志:\n' + 'npm ERR! C:\Users\jj\AppData\Roaming\npm-cache\_logs\2020-07-31T14_32_53_529Z-debug.log\n',
C:\Users\jj\AppData\Roaming\npm-cache\_logs\2020-07-31T14_32_53_529Z-debug.log\n',
Here is my package.json file这是我的 package.json 文件
{
"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": {}
}
}
}
Delete the "android" folder in the root directory.删除根目录下的“android”文件夹。
The run the command again:再次运行命令:
ionic cordova platform add android
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.