An error occurred while running cordova plugin add de.appplant.cordova.plugin.local-notification

时间:2017-07-10 15:27:09

标签: ionic-framework

While attempting to install the cordova plugins for local-notification for an Ionic Framework cross platform app I received the following:

Installing "de.appplant.cordova.plugin.local-notification" for android Plugin dependency "cordova-plugin-device@1.1.4" already fetched, using that version. Dependent plugin "cordova-plugin-device" already installed on android. Failed to install 'de.appplant.cordova.plugin.local-notification': Error at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/fetch.js:205:33

I've already tried the solution at https://github.com/katzer/cordova-plugin-local-notifications to no avail. All I'm trying to do is load the plugins as described on Ionic's site: https://ionicframework.com/docs/native/local-notifications/ and I they won't install the plugins.

$ ionic cordova plugin add de.appplant.cordova.plugin.local-notification

$ npm install --save @ionic-native/local-notifications

1 个答案:

答案 0 :(得分:0)

您很可能安装了Yarn,并且它与您的NPM版本发生冲突。尝试删除Yarn,以及node_modules并重新安装。

例如,如果您使用的是Brew,则可以执行以下操作:

# Uninstall Yarn
brew uninstall yarn
brew update
brew doctor

# Uprade Node & NPM  
brew upgrade node
npm install -g npm@latest

然后在你的项目目录中:

cd my-cordova-project
rm -rf node_modules

检查您的package.json是否有损坏的链接,例如:包依赖项,没有版本号,这些版本号从未完成的安装中停留。

{
    "name": "helloworld",
    "displayName": "HelloCordova",
    "version": "1.0.0",
    "description": "A sample Apache Cordova application that responds to the deviceready event.",
    "main": "index.js",
    "dependencies": {
        "cordova-android": "^6.2.3",

        // FAILED INSTALL MIGHT CREATE EMPTY VERSION!
        "cordova-plugin-app-version": ""
    },
    "cordova": {
        "plugins": {
            "de.appplant.cordova.plugin.local-notification": {},
            "cordova-plugin-app-version": {}
        }
    }
}

现在使用npm再次安装所有内容:

npm install

以下是我的版本信息,以帮助您调试:

node --version
v8.1.4

npm --version
5.3.0

cordova --version
7.0.1
相关问题