微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决错误: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,或在 "paths": { "@angular/*": [ "../node_modules/@angular/*" ] } 和其他方法下的 tsconfig.app.json添加 compilerOptions,但没有保存我的项目。

解决方法

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。