错误:必须从注入上下文调用inject()



我想我遵循了网上所有最喜欢的解决方案,但什么都没做。。。我有这个问题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,或在compilerOptions和其他方法下在tsconfig.app.json中添加"paths": { "@angular/*": [ "../node_modules/@angular/*" ] },但没有保存我的项目。

我通过使用ng add @angular/fire安装firebase依赖项解决了我的问题,一切都很好,没有错误!

最新更新