javascript - Angular 添加 PWA 导致 Angular Ivy 出现问题
问题描述
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 10.0.4
Node: 12.18.3
OS: darwin x64
Angular: 10.0.5
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
... service-worker
Ivy Workspace: Yes
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.1000.4
@angular-devkit/build-angular 0.1000.4
@angular-devkit/build-optimizer 0.1000.4
@angular-devkit/build-webpack 0.1000.4
@angular-devkit/core 10.0.4
@angular-devkit/schematics 10.0.4
@angular/cli 10.0.4
@ngtools/webpack 10.0.4
@schematics/angular 10.0.4
@schematics/update 0.1000.4
rxjs 6.5.5
typescript 3.9.7
webpack 4.43.0
我添加ng add @angular/pwa
到项目中。
而这一行:
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }),
导致app.module.ts
问题:
ERROR in node_modules/@angular/service-worker/service-worker.d.ts:15:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.
This likely means that the library (@angular/service-worker) which declares ServiceWorkerModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.
15 export declare class ServiceWorkerModule {
~~~~~~~~~~~~~~~~~~~
我该如何解决这个问题?
很难添加更多细节来克服 stackoverflow 解析器,而我使用 angular version 命令添加了许多细节。
解决方案
您可以在tsconfig.app.json 中将 enableIvy设置为 false,这应该可以解决您的问题
"enableIvy": false
推荐阅读
- node.js - 响应 GPS 设备
- javascript - 替代 nextElementSibling
- javascript - 我如何在反应组件之外访问 redux 存储?
- reactjs - 在 React Native 的可缩放视图中实现发布时重置
- nosql - Oracle NoSQL 数据库云服务中的服务控制台是否支持下载整个查询结果?
- ruby-on-rails - 将从序列化中恢复的 ActiveRecord 项标记为持久性
- c - 在运行时请求 Linux 功能
- python - 多维文档撤消/重做模式的Python实现
- javascript - 多重身份验证不起作用 passport.js
- python - 如何将随机性组件添加到计划中