首页 > 解决方案 > 将本机科尔多瓦插件添加到科尔多瓦项目时出现科尔多瓦错误

问题描述

首先我初始化一个cordova项目,如下所示:

cordova create hello com.example.hello hello
cordova platform add android@7.1.0

然后我执行cordova plugin add来安装一个本地的cordova插件,然后它发生如下:

JackRodeMacBook-Pro:hello jack$ cordova plugin add ~/Documents/work-flux/cordova-plugin/com-flux-location
(node:21287) UnhandledPromiseRejectionWarning: CordovaError: Failed to fetch plugin /Users/jack/Documents/work-flux/cordova-plugin/com-flux-location via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: npm: Command failed with exit code 1 Error output:
npm ERR! code ENOLOCAL
npm ERR! Could not install from "../../work-flux/cordova-plugin/com-flux-location" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/jack/.npm/_logs/2018-07-10T10_17_06_259Z-debug.log
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/fetch.js:173:37
    at _rejected (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:864:24)
    at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:890:30
    at Promise.when (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:1142:31)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:808:41)
    at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:624:44
    at runSingle (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:137:13)
    at flush (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:125:13)
    at process._tickCallback (internal/process/next_tick.js:61:11)
(node:21287) 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:21287) [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.

我检查了本机插件目录,它包含 package.json 文件。我检查了网络连接,它也很好。

我无法解决。任何人都可以帮助我吗?

标签: cordovacordova-plugins

解决方案


推荐阅读