简体   繁体   中英

Ionic 4 platform add android error code ENOLOCAL

I removed my android platform on my ionic project and tried to re-install it but I keep receiving npm ERR! code ENOLOCAL npm ERR! code ENOLOCAL . here is the error when I type platform add android :

(node:3880) UnhandledPromiseRejectionWarning: CordovaError: Error: cmd: 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\RMT016\AppData\Roaming\npm-cache\_logs\2018-09-26T08_08_46_485Z-debug.log
    at C:\Users\RMT016\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-fetch\index.js:105:29
    at _rejected (C:\Users\RMT016\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:864:24)
    at C:\Users\RMT016\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:890:30
    at Promise.when (C:\Users\RMT016\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:1142:31)
    at Promise.promise.promiseDispatch (C:\Users\RMT016\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:808:41)
    at C:\Users\RMT016\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:624:44
    at runSingle (C:\Users\RMT016\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:137:13)
    at flush (C:\Users\RMT016\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:125:13)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
(node:3880) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:3880) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate
the Node.js process with a non-zero exit code.

I tried removing and adding the platform, also removing and adding the node_modules but still get the same error. My Cordova version is 8.0 . anybody knows how to solve this?

在根目录(不是平台目录)中创建了 Android 文件夹,删除此文件夹后,命令再次运行。

从项目目录中删除 Android 文件夹

重命名该文件夹后,根目录 (而非platforms目录)中存在一个Android文件夹,该命令再次生效。就像您重命名android2一样,因为它是您的备份。

I accidentiall run the capacitor command instead of using cordova. After removing the android forlder that was created with the capacitor command it worked again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM