Ionic / Cordova: How to install ionic native plugins

395 Views Asked by At

How do I install an additional Cordova plugin into an existing Ionic/Cordova project? I need the Cordova Battery-Status Plugin. If I try:

ionic cordova plugin add cordova-plugin-battery-status

I'm getting this:

Error: Failed to fetch plugin cordova-plugin-battery-status 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 4294963248 Error output:
    npm ERR! path
    C:\development\ionic\baterry-status\battery_test\node_modules\fsevents\node_modules\ansi-regex\package.json
    npm ERR! code EPERM
    npm ERR! errno -4048
    npm ERR! syscall unlink
    npm ERR! Error: EPERM: operation not permitted, unlink
    'C:\development\ionic\baterry-status\battery_test\node_modules\fsevents\node_modules\ansi-regex\package.json'
    npm ERR!     at Error (native)
    npm ERR!  { Error: EPERM: operation not permitted, unlink
    'C:\development\ionic\baterry-status\battery_test\node_modules\fsevents\node_modules\ansi-regex\package.json'
    npm ERR!     at Error (native)
    npm ERR!   stack: 'Error: EPERM: operation not permitted, unlink
    \'C:\\development\\ionic\\baterry-status\\battery_test\\node_modules\\fsevents\\node_modules\\ansi-regex\\package.json\'\n
       at Error (native)',
    npm ERR!   errno: -4048,
    npm ERR!   code: 'EPERM',
    npm ERR!   syscall: 'unlink',
    npm ERR!   path:
    'C:\\development\\ionic\\baterry-status\\battery_test\\node_modules\\fsevents\\node_modules\\ansi-regex\\package.json'
    }
    npm ERR!
    npm ERR! Please try running this command again as root/Administrator.

    npm ERR! A complete log of this run can be found in:
    npm ERR!     C:\Users\Administrador\AppData\Roaming\npm-cache\_logs\2017-09-14T14_55_19_022Z-debug.log
1

There are 1 best solutions below

0
On BEST ANSWER

Try this, its working. i have tested before posting here

cordova plugin add cordova-plugin-battery-status

enter image description here

for more detail, go to https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-battery-status/#installation