【问题标题】:Ionic 4 platform add android error code ENOLOCALIonic 4平台添加android错误代码ENOLOCAL
【发布时间】:2018-09-26 08:19:04
【问题描述】:

我在我的 ionic 项目中删除了我的 android 平台并尝试重新安装它,但我一直收到 npm ERR! code ENOLOCAL 。这是我输入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.

我尝试删除和添加平台,也删除和​​添加 node_modules,但仍然遇到相同的错误。 我的 Cordova 版本是 8.0 。 有人知道怎么解决吗?

【问题讨论】:

    标签: android angular cordova ionic-framework


    【解决方案1】:

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

    【讨论】:

    • 我运行了电容器命令npx cap add android,它在根目录中创建了“android”目录。只需将其重命名为 android_cap 并重新运行命令cordova platform add android,它就可以完美运行。谢谢@nimzz
    • 是的,它不适合使用电容器。重命名对我有用。
    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

      我偶然运行了电容器命令而不是使用科尔多瓦。删除使用电容器命令创建的 android forlder 后,它再次工作。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-05-12
        • 2018-02-26
        • 2016-05-13
        • 1970-01-01
        • 1970-01-01
        • 2015-03-14
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多