EddyVerbruggen / nativescript-plugin-firebase

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

NativeScript 7 Firebase RC Build Fail #1729

Closed ShawnPavel closed 3 years ago

ShawnPavel commented 3 years ago

When attempting to build my app (for android or ios) with "@nativescript/firebase": "rc" I get the following errors:

node_modules/@nativescript/firebase/messaging/messaging.d.ts:1:10 - error TS2305: Module '"../firebase"' has no exported member 'Message'.

1 import { Message, MessagingOptions } from "../firebase";
           ~~~~~~~
node_modules/@nativescript/firebase/messaging/messaging.d.ts:1:19 - error TS2305: Module '"../firebase"' has no exported member 'MessagingOptions'.

1 import { Message, MessagingOptions } from "../firebase";
                    ~~~~~~~~~~~~~~~~
node_modules/@nativescript/firebase/app/firestore/index.d.ts:7:23 - error TS2503: Cannot find namespace 'firebase'.

7         FieldValue(): firebase.firestore.FieldValue;

I'm not sure how to proceed

ShawnPavel commented 3 years ago

I was able to resolve this by changing a few things.

firebase/messaging/messaging.d.ts

replace import { Message, MessagingOptions } from "../firebase"; with import { firebase }from "../firebase"; And update the references to Message and MessagingOptions to be firebase.Message and firebase.MessagingOptions respectively.

firebase/app/firestore/index.d.ts

Replace firebase.firestore.FieldValue with fStore.FieldValue

EddyVerbruggen commented 3 years ago

There's no longer a need to use the rc - please switch to the latest release.

span commented 3 years ago

I'm seeing this same error using 11.1.3.

  "dependencies": {
    "@angular/animations": "^10.0.0",
    "@angular/common": "^10.0.0",
    "@angular/core": "^10.0.0",
    "@angular/forms": "^10.0.0",
    "@angular/platform-browser": "^10.0.0",
    "@angular/platform-browser-dynamic": "^10.0.0",
    "@angular/router": "^10.0.0",
    "@nativescript/angular": "^10.0.0",
    "@nativescript/core": "^7.0.13",
    "@nativescript/firebase": "^11.1.3",
    "@nativescript/theme": "^3.0.1",
    "@nativescript/webpack": "^3.0.8",
    "ajv": "^6.10.0",
    "nativescript": "^7.0.0",
    "nativescript-cardview": "^3.2.0",
    "nativescript-floatingactionbutton": "^5.1.0",
    "nativescript-modal-datetimepicker": "^2.1.2",
    "nativescript-ui-gauge": "^7.0.2",
    "reflect-metadata": "~0.1.12",
    "rxjs": "^6.4.0",
    "tns-android": "^6.4.1",
    "tns-ios": "^6.5.2",
    "zone.js": "^0.10.3"
  },
  "devDependencies": {
    "@angular/compiler": "^10.2.3",
    "@angular/compiler-cli": "^10.2.3",
    "@nativescript/android": "7.0.1",
    "@nativescript/types": "^7.0.4",
    "@ngtools/webpack": "~10.0.0",
    "bufferutil": "^4.0.1",
    "fibers": "^3.1.1",
    "marked": "^0.5.0",
    "node-sass": "^4.0.0",
    "sass": "^1.3.2",
    "typescript": "3.9.7",
    "utf-8-validate": "^5.0.2"
  },

Build fails with:

Entrypoint bundle = runtime.js vendor.js bundle.js
[./app.scss] 11.6 KiB {bundle} [built]
[./main.ts] 1.13 KiB {bundle} [built]
[~/package.json] external "~/package.json" 42 bytes {bundle} [optional] [built]
    + 328 hidden modules

ERROR in node_modules/@nativescript/firebase/messaging/messaging.d.ts:1:10 - error TS2305: Module '"../firebase"' has no exported member 'Message'.

1 import { Message, MessagingOptions } from "../firebase";
           ~~~~~~~
node_modules/@nativescript/firebase/messaging/messaging.d.ts:1:19 - error TS2305: Module '"../firebase"' has no exported member 'MessagingOptions'.

1 import { Message, MessagingOptions } from "../firebase";

Changing messaging.d.ts from:

import { Message, MessagingOptions } from "../firebase";

export declare function initFirebaseMessaging(options?: MessagingOptions): void;
...

To:

import { firebase } from "../firebase";

export declare function initFirebaseMessaging(options?: firebase.MessagingOptions): void;
...

Makes vscode stop complaining at least.

Tns doctor:

$ tns doctor
Error while loading nativescript-cloud is: Default commands should be required before child commands
(node:17282) ExperimentalWarning: The fs.promises API is experimental
✔ Getting environment information

No issues were detected.
✔ Your ANDROID_HOME environment variable is set and points to correct directory.
✔ Your adb from the Android SDK is correctly installed.
✔ The Android SDK is installed.
✔ A compatible Android SDK for compilation is found.
✔ Javac is installed and is configured properly.
✔ The Java Development Kit (JDK) is installed and is configured properly.
✔ Xcode is installed and is configured properly.
✔ xcodeproj is installed and is configured properly.
✔ CocoaPods are installed.
✔ CocoaPods update is not required.
✔ CocoaPods are configured properly.
✔ Your current CocoaPods version is newer than 1.0.0.
✔ Python installed and configured correctly.
✔ The Python 'six' package is found.
✔ Xcode version 12.2.0 satisfies minimum required version 10.
✔ Getting NativeScript components versions information...
✔ Component nativescript has 7.0.11 version and is up to date.
✔ Component @nativescript/core has 7.0.13 version and is up to date.
✖ Component @nativescript/ios is not installed.
✔ Component @nativescript/android has 7.0.1 version and is up to date.