【问题标题】:import * as firebase from 'firebase' no longer working as of Angular 6 updateimport * as firebase from 'firebase' 自 Angular 6 更新起不再工作
【发布时间】:2018-07-22 23:49:04
【问题描述】:

我最近将我的 Angular 5 项目更新为 Angular 6,并且我整天都在尝试构建和部署。我的最新问题是导入问题 - 之前工作正常。

错误现在在我的导入中显示cannot find module 'firebase'

【问题讨论】:

  • 在你的package.json 中确定它是一个依赖项吗?在更新后你是npm install 吗?如果是这样,npm 可能会很奇怪,Intellisense 也是如此。一个好的 ol'rm -rf /node_modules && npm cache clean && npm install 可以解决它。
  • 请勿发布文字图片。

标签: angular firebase import angular6


【解决方案1】:

对于 Angular 6+,导入 firebase 核心和服务如下:

/*
* reduce the amount of code that your app uses by 
* only including the features that you need.
*/

// import core firebase client (required)
import firebase from '@firebase/app';

// import Firebase Authentication (optional)
import '@firebase/auth';

// import Firebase Realtime Database (optional)
import '@firebase/database';

// import Cloud Firestore (optional)
import '@firebase/firestore';

请联系official docs 了解更多信息。

【讨论】:

    猜你喜欢
    • 2021-11-08
    • 1970-01-01
    • 2021-04-12
    • 2020-05-11
    • 1970-01-01
    • 1970-01-01
    • 2014-12-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多