简体   繁体   中英

Cannot install Ionic-Native File plugin

I have an Ionic 3 project to which I am trying add Ionic Native File plugin, using the command:

ionic cordova plugin add cordova-plugin-file

However, I am getting the following error:

L:\MyTrials\test\ionic\locations-app>ionic cordova plugin add cordova-plugin-file
> cordova plugin add cordova-plugin-file --save
x Running command - failed!
[ERROR] An error occurred while running cordova plugin add cordova-plugin-file

    --save (exit code 1):

    Error: Failed to fetch plugin file:node_modules\cordova-plugin-file 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 ERR! code ENOLOCAL
    npm ERR! Could not install from "node_modules\cordova-plugin-file" as it
    does not contain a package.json file.

    npm ERR! A complete log of this run can be found in:
    npm ERR!
    C:\Users\xxx\AppData\Roaming\npm-cache\_logs\2017-09-21T05_16_31_940Z-debug.log

I have already tried other command such as:

cordova plugin add cordova-plugin-file

and

cordova plugin add cordova-plugin-file --nofetch

but I am basically getting the same error.

My internet connection is fine and I ran these commands as Administrator.

It seems that only the File plugin may be having these issues. I could install the Ionic Native Datepicker plugin without any issues.

Any help is appreciated!

As can be seen in the question's comments, with the help of @amin arghavani, doing the following resolved the issue:

  1. Remove the plugin if its already installed: ionic cordova plugin rm cordova-plugin-file In my case this plugin was never installed so I got the same message as an error.

  2. Check if a folder for the plugin is present under the project's node_modules folder. In my case I actually found a shortcut link named after the plugin ( cordova-plugin-file ) which I've deleted.

  3. Check if plugin is included in the project's package.json as a dependency or developer dependency. In my case I found the reference to cordova-plugin-file under dependencies (which I deleted and saved) in package.json .

  4. Add the cordova component again from commandline which worked for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM