EddyVerbruggen / nativescript-plugin-firebase

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

Issue Building - Can't Resolve 2 tns-core-module(s) #1663

Closed NativeScriptNewb closed 3 years ago

NativeScriptNewb commented 3 years ago

Hi!

I'm having some issues over here with getting this plugin in my project. After installing, placing .plist and .json in their appropriate places, and placing the init command in my app.js, my app won't build. I've tried removing platforms and even building three separate new test apps and I continue to have the same issue.

Steps followed:

  1. Created plain JS app via NS CLI
  2. Installed nativescript-plugin-firebase via NS CLI.
  3. Got the .plist and .json files from FB and put them in their respective platform folders.
  4. Introduced the init commands and console log in app.js

Each time I get this error when trying to build my project:

ERROR in ../node_modules/nativescript-plugin-firebase/firebase.js Module not found: Error: Can't resolve 'tns-core-modules/application/application' in '/Users/robertroussel/ng/fbtest/node_modules/nativescript-plugin-firebase' @ ../node_modules/nativescript-plugin-firebase/firebase.js 4:18-69 @ ./app.js

ERROR in ../node_modules/nativescript-plugin-firebase/messaging/messaging.js Module not found: Error: Can't resolve 'tns-core-modules/application/application' in '/Users/robertroussel/ng/fbtest/node_modules/nativescript-plugin-firebase/messaging' @ ../node_modules/nativescript-plugin-firebase/messaging/messaging.js 5:18-69 @ ../node_modules/nativescript-plugin-firebase/firebase.js @ ./app.js

ERROR in ../node_modules/nativescript-plugin-firebase/admob/admob.js Module not found: Error: Can't resolve 'tns-core-modules/platform/platform' in '/Users/robertroussel/ng/fbtest/node_modules/nativescript-plugin-firebase/admob' @ ../node_modules/nativescript-plugin-firebase/admob/admob.js 3:17-62 @ ../node_modules/nativescript-plugin-firebase/firebase-common.js @ ../node_modules/nativescript-plugin-firebase/firebase.js @ ./app.js

ERROR in ../node_modules/nativescript-plugin-firebase/messaging/messaging.js Module not found: Error: Can't resolve 'tns-core-modules/platform/platform' in '/Users/robertroussel/ng/fbtest/node_modules/nativescript-plugin-firebase/messaging' @ ../node_modules/nativescript-plugin-firebase/messaging/messaging.js 6:17-62 @ ../node_modules/nativescript-plugin-firebase/firebase.js @ ./app.js Executing webpack failed with exit code 2.

package.json contents: { "name": "@nativescript/template-hello-world", "main": "app.js", "version": "7.0.1", "author": "NativeScript Team oss@nativescript.org", "description": "NativeScript Application", "license": "SEE LICENSE IN ", "publishConfig": { "access": "public" }, "keywords": [ "nstudio", "nativescript", "mobile", "{N}", "tns", "template" ], "repository": "", "bugs": { "url": "https://github.com/NativeScript/NativeScript/issues" }, "homepage": "https://github.com/NativeScript/nativescript-app-templates", "dependencies": { "@nativescript/core": "~7.0.0", "@nativescript/theme": "~2.3.0", "nativescript-plugin-firebase": "^10.5.2" }, "devDependencies": { "@nativescript/ios": "7.0.0", "@nativescript/webpack": "~3.0.0" }, "gitHead": "3c1e356f5a73a8feb68acc40b3c7c02c9d18d7f0", "private": "true", "readme": "NativeScript Application" }

I initially felt as though I over looked something, as I could have sworn I had this plugin initializing on a simple hello world I toyed around with when first introduced to NS earlier this year, but now I'm wondering if there is something else going on..? I'm hoping it's something simple I've missed! Any help you ya'll can offer would be greatly appreciated!

ovaltechnologiesinc commented 3 years ago

Facing the same challenge. I read almost every resource I could find to no avail. I understand this challenge began whe nativescript was updated to 7.0.6 and above.

This is a critical component of my app and I have been stuck at if for the last 5 days.

qasim483 commented 3 years ago

I was able to solve it using "@nativescript/firebase": "^11.0.0-rc.0". import * as firebase from @nativescript/firebase

check this link: https://nativescript.org/blog/nativescript-7-compatible-plugins/

crowmagnumb commented 3 years ago

You can now write that import statement in the standard way, i.e.

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

NativeScriptNewb commented 3 years ago

Thanks! Importing it from @nativescript/firebase as multiple people suggested fixed it for me. Thanks everyone!

RibuRoyson commented 3 years ago

I am in this weird situation..updated my project to ns 7 and updated firebase to @nativescript/firebase.. wherever i use this line import { firebase } from "@nativescript/firebase"; my layout design changes awkardly.