“FirebaseApp”

时间:2018-04-11 20:23:49

标签: firebase ionic-framework google-cloud-functions

我一直试图使用Firebase Documentation

中描述的可调用语法从我的Ionic应用程序调用Firebase云功能

我还在StackOverflow中找到了此前的question,这似乎是我正在寻找的正确答案......

我遇到的问题是,我无法使用“离子构建”构建代码,因为它给出了以下错误:“FirebaseApp”类型中不存在属性“函数”

我的代码如下所示:

import firebase from 'firebase';
import '@firebase/functions';
import { ConfigSettings } from '../shared/app.config';

const firebaseApp = firebase.initializeApp(ConfigSettings);
const functions = firebaseApp.functions();

以下是我的package.json中的dependecies:

"dependencies": {
  "@angular/common": "5.0.3",
  "@angular/compiler": "5.0.3",
  "@angular/compiler-cli": "5.0.3",
  "@angular/core": "5.0.3",
  "@angular/forms": "5.0.3",
  "@angular/http": "5.0.3",
  "@angular/platform-browser": "5.0.3",
  "@angular/platform-browser-dynamic": "5.0.3",
  "@firebase/functions": "^0.1.0",
  "@ionic-native/contacts": "^4.6.0",
  "@ionic-native/core": "4.4.0",
  "@ionic-native/facebook": "^4.5.3",
  "@ionic-native/firebase-dynamic-links": "^4.6.0",
  "@ionic-native/google-plus": "^4.5.3",
  "@ionic-native/social-sharing": "^4.6.0",
  "@ionic-native/splash-screen": "4.4.0",
  "@ionic-native/status-bar": "4.4.0",
  "@ionic/pro": "1.0.20",
  "@ionic/storage": "^2.1.3",
  "angularfire2": "^5.0.0-rc.6",
  "cordova-android": "6.4.0",
  "cordova-plugin-contacts": "^3.0.1",
  "cordova-plugin-device": "^2.0.1",
  "cordova-plugin-facebook4": "^1.9.1",
  "cordova-plugin-firebase-dynamiclinks": "^0.13.1",
  "cordova-plugin-googleplus": "^5.2.1",
  "cordova-plugin-ionic-keyboard": "^2.0.5",
  "cordova-plugin-ionic-webview": "^1.1.16",
  "cordova-plugin-splashscreen": "^5.0.2",
  "cordova-plugin-whitelist": "^1.3.3",
  "cordova-plugin-x-socialsharing": "^5.3.2",
  "cordova-sqlite-storage": "^2.2.1",
  "cordova-support-google-services": "^1.1.0",
  "cors": "^2.8.4",
  "es6-promise-plugin": "^4.2.2",
  "firebase": "^4.12.1",
  "ionic-angular": "3.9.2",
  "ionicons": "3.0.0",
  "rxjs": "5.5.2",
  "sw-toolbox": "3.6.0",
  "zone.js": "0.8.18"
}

1 个答案:

答案 0 :(得分:0)

您不应该尝试使用Ionic App编译@firebase/functions包。

在本地调用函数来测试您的构建 - 它们不应与您的应用程序捆绑在一起。编译应用程序时,您可以通过正确的方法(如实时数据库触发器或HTTP触发器)调用您的函数,而不是使用@firebase/functions包。

您链接到的说明 用于在您的开发环境中进行设置。它们与您的应用程序构建是分开的 - 也许您应该尝试将这些独立文件放在不同于Ionic App的单独目录中,这样它们就不会混淆。