2

我正在尝试将“文件”插件添加到我的 Phonegap 项目中,但它返回错误:

d:\Android\projects\myProject>phonegap plugin add cordova-plugin-file
Error: Failed to fetch plugin git+https://github.com/apache/cordova-plugin-file.git via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: cmd: Command failed with exit code 1 Error output:
npm WARN cordova-plugin-camera@2.1.1 requires a peer of cordova-plugin-file@>=2.0.0 but none was installed.
npm WARN cordova-plugin-file-transfer@1.5.1 requires a peer of cordova-plugin-file@^3.0.0 but none was installed.
npm WARN cordova-plugin-media-capture@1.2.0 requires a peer of cordova-plugin-file@^3.0.0 but none was installed.
npm WARN com.phonegap.helloworld@1.0.0 No repository field.
npm WARN com.phonegap.helloworld@1.0.0 No license field.
npm ERR! code 1

将“文件”插件添加到 Phonegap/Cordova 项目的正确方法是什么?

ps:我在Windows cmd上。

更新:

尝试添加--save启用选项的插件:

d:\Android\projects\myProject>phonegap plugin add cordova-plugin-file --save -d
No scripts found for hook "before_plugin_add".

No version specified for cordova-plugin-file, retrieving version from package.json

Calling plugman.fetch on plugin "cordova-plugin-file@^4.0.0"

saving

Running command: cmd "/s /c "D:\xampp\nodejs\npm.cmd install cordova-plugin-file@^4.0.0 --save""

Command finished with error code 1: cmd /s /c "D:\xampp\nodejs\npm.cmd install cordova-plugin-file@^4.0.0 --save"

Error: Failed to fetch plugin cordova-plugin-file@^4.0.0 via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: cmd: Command failed with exit code 1 Error output:
npm WARN cordova-plugin-file-transfer@1.5.1 requires a peer of cordova-plugin-file@^3.0.0 but none was installed.
npm WARN cordova-plugin-media-capture@1.2.0 requires a peer of cordova-plugin-file@^3.0.0 but none was installed.
npm WARN com.phonegap.helloworld@1.0.0 No repository field.
npm WARN com.phonegap.helloworld@1.0.0 No license field.
npm ERR! code 1
4

1 回答 1

0

看起来它是cordova版本的错误。你用的是哪个版本?。尝试使用其他版本,例如 6.5.0

npm i cordova@6.5.0

再次尝试安装插件

cordova plugin add cordova-plugin-file

请让我知道这对你有没有用

于 2017-09-20T12:44:35.610 回答