4

错误

node_modules/angular-datatables/src/angular-datatables.module.d.ts(8,22) 中的错误:错误 TS-996002:出现在 AppModule 的 NgModule.imports 中,但无法解析为 NgModule 类 node_modules/ ng2-select2/ng2-select2.d.ts(3,22):错误 TS-996002:出现在 AppModule 的 NgModule.imports 中,但无法解析为 NgModule 类

吴版

            Angular CLI: 8.0.3
            Node: 12.4.0
            OS: win32 x64
            Angular: 8.0.1
            ... animations, cdk, common, compiler, compiler-cli, core, forms
            ... language-service, material, platform-browser
            ... platform-browser-dynamic, router, service-worker

            Package                           Version
            -----------------------------------------------------------
            @angular-devkit/architect         0.800.3
            @angular-devkit/build-angular     0.800.3
            @angular-devkit/build-optimizer   0.800.3
            @angular-devkit/build-webpack     0.800.3
            @angular-devkit/core              8.0.3
            @angular-devkit/schematics        8.0.3
            @angular/cli                      8.0.3
            @angular/http                     7.2.15
            @angular/pwa                      0.800.3
            @ngtools/webpack                  8.0.3
            @schematics/angular               8.0.3
            @schematics/update                0.800.3 (cli-only)
            rxjs                              6.5.2
            typescript                        3.4.5
            webpack                           4.30.0

参考 https://angular.io/guide/ivy

Angular.json

        "architect": {
            "build": {
              "builder": "@angular-devkit/build-angular:browser",
              "options": {
                "outputPath": "dist",
                "index": "src/index.html",
                "aot": true,    

tsconfig.app.json

            {
          "extends": "../tsconfig.json",
          "compilerOptions": {
            "outDir": "../out-tsc/app",
            "baseUrl": "./",
            "module": "es2015",
            "types": []
          },
          "angularCompilerOptions": {
            "enableIvy": true
          },

通过将标志设置为假工作

 "angularCompilerOptions": {
"enableIvy": false
 },

问题

  • 整合常春藤错误后重现。
  • 试图删除节点模块

  • 在配置文件中删除常春藤时,ng serve 工作正常。

  • 欢迎任何建议

4

2 回答 2

2

I ran into the same issue. using Angular9.

this might not work for you but it did work for me.

cancelling ng serve and running it again somehow fixed it.

I also saw many threads about people with the same issue and like you said they turned off ivy rendered because it's causing bugs since it isn't complete yet.

于 2019-12-27T00:41:14.473 回答
-1

升级到 Angular 9 对我有用 ng update @angular/cli@9 @angular/core@9 --allow-dirty

于 2020-02-24T04:05:13.430 回答