Ionic / Cordova:如何安装 ionic 本机插件

Ionic / Cordova: How to install ionic native plugins

如何将额外的 Cordova 插件安装到现有的 Ionic/Cordova 项目中?我需要 Cordova 电池状态插件。如果我尝试:

ionic cordova plugin add cordova-plugin-battery-status

我明白了:

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\_logs17-09-14T14_55_19_022Z-debug.log

试试这个,它的工作。我在发帖前测试过

cordova plugin add cordova-plugin-battery-status

有关更多详细信息,请访问 https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-battery-status/#installation