即使在 angular 中编译成功,也无法在浏览器中获得输出

Not getting output in browser even compilation is successful in angular

    core.js:4031 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:4031)
    at Function.get (core.js:26915)
    at getNgModuleDef (core.js:1117)
    at assertNgModuleType (core.js:1296)
    at compileNgModuleFactory__POST_R3__ (core.js:29062)
    at PlatformRef.boo**strong text**tstrapModule (core.js:29309)
    at Module.4431 (main.ts:11)
    at __webpack_require_***strong text***_ (bootstrap:19)
    at __webpack_exec__ (main.js:223)
    at main.js:224

即使在更新我的 npm 后,我仍会收到此类错误

根据 (https://github.com/angular/angular-cli/issues/16873)(建议阅读之前的 link,因为我将很快解释)这个问题可以通过以下方式解决:

1-运行 npm update 更新您的依赖项。

2-你有一个 angular.json 文件,其中应该包含一个 aot=true,如果不是简单地自己添加,则添加 postinstall": "ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points然后删除node_modules并打包锁文件重新安装。

3-在 tsconfig.json 文件 "angularCompilerOptions": { "fullTemplateTypeCheck": true, "strictInjectionParameters": true, "enableIvy": false }

上禁用你的 ivy 引擎

4-有时,如果您降级 angular Cli 版本,问题就会得到解决。