gpt4 book ai didi

cordova - 安装 cordova 插件时出错

转载 作者:行者123 更新时间:2023-12-04 03:07:54 25 4
gpt4 key购买 nike

我正在开发一个依赖于其他插件的 cordova 插件。如果不传递 --fetch 参数,我将无法安装插件。

这是我的插件依赖项在原始插件的 xml 文件中的样子:

<dependency url="https://bitbucket.org/MY_REPO_URL" id="SOME_PLUGIN_ID"/>
<dependency url="https://bitbucket.org/MY_REPO_URL" id="SOME_OTHER_PLUGIN_ID" subdir="SOME_SUBDIR"/>

当我尝试在不使用 --nofetch 的情况下安装原始插件时:

cordova plugin add ORIGINAL_PLUGIN_ID

我收到以下错误:

No scripts found for hook "before_plugin_add".
No version specified for SOME_PLUGIN_NAME, retrieving version from package.json
Calling plugman.fetch on plugin "SOME_PLUGIN_NAME@^2.4.3"
saving
Running command: npm install SOME_PLUGIN_NAME@^2.4.3 --production --save
Command finished with error code 0: npm install,SOME_PLUGIN_NAME@^2.4.3,--production,--save
Copying plugin ".../test/node_modules/ORIGINAL_PLUGIN_ID" => ".../test/plugins/ORIGIAL_PLUGIN_ID"
Calling plugman.install on plugin ".../test/plugins/ORIGINAL_PLUGIN_ID" for platform "android
Installing "ORIGINAL_PLUGIN_ID" for android
Running command: .../test/platforms/android/cordova/version
Command finished with error code 0: .../test/platforms/android/cordova/version
Dependencies detected, iterating through them...
Requesting plugin "SOME_PLUGIN_ID".
Plugin dependency "SOME_PLUGIN_ID" not fetched, retrieving then installing.
saving
Running command: npm install https://bitbucket.org/MY_REPO_URL --production --save
Command finished with error code 0: npm install,https://bitbucket.org/MY_REPO_URL,--production,--save
Failed to install 'ORIGINAL_PLUGIN_ID': Error
at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/fetch.js:215:37
at _rejected (/usr/local/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:864:24)
at /usr/local/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:890:30
at Promise.when (/usr/local/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:1142:31)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:808:41)
at /usr/local/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:624:44
at runSingle (/usr/local/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:137:13)
at flush (/usr/local/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
Error: Failed to fetch plugin https://bitbucket.org/MY_REPO_URL via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
TypeError: Parameter "url" must be a string, not undefined

如果我使用 --nofetch,安装工作完美。

cordova plugin add ORIGINAL_PLUGIN_NAME --nofetch

我想知道是否有什么我可以做的,这样我就可以在不使用 --nofetch

的情况下添加插件

最佳答案

我们通过在 npm 中发布依赖项并删除 subdir 和 url 属性(仅添加插件 ID)解决了这个问题。

现在我们可以将不带--nofetch 的插件添加到项目中。

我还发现 subdir 功能在 cordova 内部被弃用,因为 npm 成为默认选项。不幸的是,这没有记录在案,依赖项的 subdir 选项是 still documented作为受支持且未弃用的功能。

关于cordova - 安装 cordova 插件时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47437225/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com