EddyVerbruggen / nativescript-plugin-firebase

:fire: NativeScript plugin for Firebase
https://firebase.google.com
MIT License
1.01k stars 448 forks source link

Error: Can't resolve 'tns-core-modules/application/application' #1708

Closed rnmhdn closed 3 years ago

rnmhdn commented 3 years ago

I got this error while building:

ERROR in ../node_modules/nativescript-plugin-firebase/messaging/messaging.js
Module not found: Error: Can't resolve 'tns-core-modules/application/application' in '/home/me/projects/test/app/eleos/node_modules/nativescript-plugin-firebase/messaging'
 @ ../node_modules/nativescript-plugin-firebase/messaging/messaging.js 11:18-69
 @ ../node_modules/nativescript-plugin-firebase/firebase.js
 @ ./store.js
 @ ./main.js

package version: nativescript-plugin-firebase: ^10.5.2,

I solved it by replacing

var appModule = require("tns-core-modules/application");
var application = require("tns-core-modules/application/application");

with

var appModule = require("tns-core-modules/application");
var application = appModule.application

in node_modules/nativescript-plugin-firebase/messaging/messaging.android.js

I didn't try building on ios yet.

rnmhdn commented 3 years ago

This was caused because I updated to ns 7 but was still useing the old version of this plugin. the following solved my issue:

ns plugin remove nativescript-plugin-firebase
ns plugin add @nativescript/firebase

And I import it like so:

import {firebase} from '@nativescript/firebase';