Adding cordova-plugin-file error

2.4k Views Asked by At

I'm trying to add "file" plugin to my Phonegap project, but it's returns errors:

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 [email protected] requires a peer of cordova-plugin-file@>=2.0.0 but none was installed.
npm WARN [email protected] requires a peer of cordova-plugin-file@^3.0.0 but none was installed.
npm WARN [email protected] requires a peer of cordova-plugin-file@^3.0.0 but none was installed.
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.
npm ERR! code 1

What is the right way of adding "file" plugin to Phonegap/Cordova project?

p.s: I'm on Windows cmd.

Update:

Trying to add plugin with --save option enabled:

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 [email protected] requires a peer of cordova-plugin-file@^3.0.0 but none was installed.
npm WARN [email protected] requires a peer of cordova-plugin-file@^3.0.0 but none was installed.
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.
npm ERR! code 1
1

There are 1 best solutions below

1
On

It looks like its an error with the cordova version. Which version do you use it ?. Try with another version, for example 6.5.0

npm i [email protected]

Try again to install a plugin

cordova plugin add cordova-plugin-file

Let me know if it works for you