cordova无法正确添加插件

时间:2018-09-25 15:59:24

标签: android cordova

每次添加插件时,都会收到以下消息:

(node:27816) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at getJson (C:\Users\bdavis\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\plugman\util\metadata.js:29:31)
    at Object.exports.get_fetch_metadata (C:\Users\bdavis\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\plugman\util\metadata.js:41:24)
    at C:\Users\bdavis\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\platform\addHelper.js:343:48
    at _fulfilled (C:\Users\bdavis\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:787:54)
    at self.promiseDispatch.done (C:\Users\bdavis\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:816:30)
    at Promise.promise.promiseDispatch (C:\Users\bdavis\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:749:13)
    at C:\Users\bdavis\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:810:14
    at flush (C:\Users\bdavis\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:108:17)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
(node:27816) 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:27816) [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.

它实际上确实安装了插件,但没有创建cordova_plugins.js。当我尝试删除和读取平台时,它也可以工作到cordova_plugins.js步骤为止,因此我认为它与创建或更新该文件有关。该项目将在iOS上构建并正常运行;它将为Android构建并运行,但是由于无法加载插件而导致运行时错误。

尝试:

  • npm重新安装Sun之下的所有内容
  • 关闭并重新打开Visual Studio
  • 抱怨

我当时想尝试哭泣,但我不知道那会成功。想想我这里可能还有更多的运气。

版本:

  • 节点10.11
  • npm 6.4.1
  • cordova 8.0.0
  • cordova-android 6.4.0

更新9/27 14:20 EST: 因此缺少plugins / android.json。我从硬盘上的其他位置复制了该文件,并尝试执行平台添加/删除操作,但它给出了另一个错误(下面复制),随后android.json再次从plugins目录中消失了。

$ cordova platform add android
Using cordova-fetch for cordova-android@~7.0.0
(node:11704) UnhandledPromiseRejectionWarning: CordovaError: Failed to fetch platform cordova-android@~7.0.0
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: cmd: Command failed with exit code 4294963248 Error output:

0 个答案:

没有答案