问题描述
我想我遵循了网络上所有最喜欢的解决方案,但没有做...
我有这个问题Error: inject() must be called from an injection context
不仅如此,我还有多个警告,例如 Warning: ###/src/app/app.module.ts depends on 'angularfire2/firestore'. Commonjs or AMD dependencies can cause optimization bailouts. For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies
因为在安装和尝试使用 npm install angularfire2 firebase --save
之前一切正常:没有错误也没有警告......
那么有人遇到过同样的问题吗?
我尝试在 angular.json 中添加 projects.$name.architect.build.options.preserveSymlinks: true
,或在 "paths": { "@angular/*": [ "../node_modules/@angular/*" ] }
和其他方法下的 tsconfig.app.json
中添加 compilerOptions
,但没有保存我的项目。
解决方法
我通过使用 ng add @angular/fire
安装 firebase 依赖项解决了我的问题,一切正常,没有错误!