添加cordova-plugin-file错误

时间:2017-09-17 15:48:10

标签: cordova cordova-plugins phonegap cordova-plugin-file

我正在尝试将“file”插件添加到我的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项目的正确方法是什么?

p.s:我在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

1 个答案:

答案 0 :(得分:0)

看起来它与cordova版本有关。你用哪个版本?尝试使用其他版本,例如6.5.0

npm i cordova@6.5.0

再次尝试安装插件

cordova plugin add cordova-plugin-file

让我知道它是否适合你