angular - 从 Angular 8 迁移后的 Angular 9 编译错误
问题描述
我将我的 Angular 应用程序从版本 8 迁移到了 9。运行 ng serve --open 后,我的应用程序在浏览器中打开并卡在加载屏幕上,并在控制台窗口中显示此错误:
`
core.js:610 Uncaught Error: Angular JIT compilation failed: '@angular/compiler' not loaded!
- JIT compilation is discouraged for production use-cases! Consider AOT mode instead.
- Did you bootstrap using '@angular/platform-browser-dynamic' or '@angular/platform-server'?
- Alternatively provide the compiler with 'import "@angular/compiler";' before bootstrapping.
at getCompilerFacade (core.js:610)
at Function.get (core.js:38351)
at getNgModuleDef (core.js:2195)
at assertNgModuleType (core.js:2933)
at compileNgModuleFactory__POST_R3__ (core.js:41373)
at PlatformRef.bootstrapModule (core.js:41740)
at Module../src/main.ts (main.ts:11)
at __webpack_require__ (bootstrap:79)
at Object.0 (main.ts:13)
at __webpack_require__ (bootstrap:79)
`
解决方案
如果您缺少模块,请检查 app.module.ts ...例如,有时在模块文件中人们导入 HttpClient 而不是HttpClientModule或者可能是因为有角度的材料,例如人们有时使用 MatButton 而不是MatButtonModule会导致这个问题.
推荐阅读
- java - Maven 依赖项和类路径
- javascript - 将JSON数组插入数据库php
- unity3d - 枪与 fps 相机统一上下移动
- r - 屏蔽 R 中特定区域的 NetCDF 文件时出错?
- xcode - SKProductsRequest 在 Xcode 12 GM 中的 UI 测试和 SKTestSession 中失败
- javascript - 从单词中获取对象值
- javascript - 毫秒到可读日期
- java - 使用 TransitionDrawable 时应用程序崩溃
- regex - zabbix vfs.file.regmatch 正则表达式
- javascript - Expo无法从ios上的文件系统目录读取文件