无法在离子2应用程序中添加fcm插件

时间:2018-02-09 12:38:32

标签: ionic2 ionic3 ionic-native cordova-plugin-fcm

我正在尝试在我的项目中添加fcm插件,但它显示以下错误

 ionic cordova plugin add cordova-plugin-fcm
> cordova plugin add cordova-plugin-fcm --save
Error: Failed to fetch plugin file:node_modules/cordova-plugin-fcm 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 4294963238 Error output:
npm ERR! addLocal Could not install F:\PROJECTS\IONIC2\foodJunctionMobileApp\node_modules\cordova-plugin-fcm
npm ERR! Windows_NT 10.0.16299
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "file:node_modules/cordova-plugin-fcm" "--production" "--save"
npm ERR! node v6.9.5
npm ERR! npm  v3.10.10
npm ERR! path F:\PROJECTS\IONIC2\foodJunctionMobileApp\node_modules\cordova-plugin-fcm
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open

npm ERR! enoent ENOENT: no such file or directory, open 'F:\PROJECTS\IONIC2\foodJunctionMobileApp\node_modules\cordova-plugin-fcm'
npm ERR! enoent ENOENT: no such file or directory, open 'F:\PROJECTS\IONIC2\foodJunctionMobileApp\node_modules\cordova-plugin-fcm'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! Please include the following file with any support request:
npm ERR!     F:\PROJECTS\IONIC2\foodJunctionMobileApp\npm-debug.log

这是我的

离子信息

cli packages: (C:\Users\Rohit\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.0
    ionic (Ionic CLI) : 3.19.0

global packages:

    cordova (Cordova CLI) : 7.1.0

local packages:

    @ionic/app-scripts : 3.1.6
    Cordova Platforms  : android 6.3.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 25.2.5
    Node              : v6.9.5
    npm               : 3.10.10
    OS                : Windows 10

Environment Variables:

    ANDROID_HOME : C:\Users\Rohit\AppData\Local\Android\sdk

Misc:

    backend : pro

我已连接到互联网,所以这不是问题。我在安装fcm之前添加了google plus插件,那时它与fcm插件冲突,所以我删除了google plus插件并尝试安装fcm但是失败了。如果有人知道的话,请提供帮助。谢谢。

2 个答案:

答案 0 :(得分:0)

我使用这个firebase插件:

https://www.npmjs.com/package/cordova-plugin-firebase

这是你可以安装它的方法:

cordova plugin add cordova-plugin-firebase@0.1.24 --save

它也适用于lates离子版。

答案 1 :(得分:0)

您可以按照本教程,解释在此过程中可以获得的所有错误,希望这会有所帮助。

https://www.djamware.com/post/58a1378480aca7386754130a/ionic-2-fcm-push-notification