Angular 13, TypeError: _angular_core__WEBPACK_IMPORTED_MODULE_12__.ɵɵstartElement(...) is not a function

Angular 13, TypeError: _angular_core__WEBPACK_IMPORTED_MODULE_12__.ɵɵstartElement(...) is not a function

应用程序成功构建并 ng 服务 运行s。申请不会成功run/initialize.

从工作时到发生故障时,打字稿代码没有明显变化,所以我专注于 html 模板和带有上下文的 tsconfig。

当生成的main.js的html模板逻辑为运行时,执行失败somewhere/somehow在第二个子元素elementStart函数执行

core.mjs:6461 ERROR TypeError: _angular_core__WEBPACK_IMPORTED_MODULE_12__.ɵɵelementStart(...) is not a function
    at AppComponent_Template (app.component.html:2:1)
    at executeTemplate (core.mjs:9593:9)
    at renderView (core.mjs:9396:13)
    at renderComponent (core.mjs:10677:5)
    at renderChildComponents (core.mjs:9261:9)
    at renderView (core.mjs:9421:13)
    at ComponentFactory.create (core.mjs:21574:13)
    at ApplicationRef.bootstrap (core.mjs:26377:42)
    at core.mjs:26060:64
    at Array.forEach (<anonymous>)

app.component.html(d-xxx 元素来自自定义构建 angular 库我也 build/manage 已与其他消费客户一起测试并正在处理其他项目)

<div>
  <d-layout [staticNavItems]="navItems" [dynamicNavItems]="contextMenuItems" [subMenuButtonLabel]="subMenuLabel"
    subMenuButtonIcon="folder" [loadingMessage]="loadingMessage">
    <div>
      <d-nav-header>
        <div class="d__logo"></div>
        <span class="d__title">
          Some Title
        </span>
      </d-nav-header>
    </div>
    <div>
      <d-content-header class="d__header">
        <d-context-subject></d-context-subject>
        <d-header></d-header>
      </d-content-header>
    </div>
    <div>
      <d-content>
        <router-outlet></router-outlet>
      </d-content>
    </div>
  </d-layout>
</div>

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "module": "esnext",
    "importHelpers": true,
    "target": "es2020",
    "lib": [
      "es2015",
      "es2018",
      "es2020",
      "dom"
    ]
  },
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true
  }
}

即使在 package.json 文件中为所有 angular 库指定的版本应该在整个板上产生相同的版本,但 angular/compiler 和 angular/core(以及其他重要的 angular 库)。

Angular: 13.1.3    <===================
... animations, common, core, forms, platform-browser

Package                             Version
-------------------------------------------------------------
@angular-devkit/architect           0.1302.5
@angular-devkit/build-angular       13.2.5 <================
@angular-devkit/core                13.2.5
@angular-devkit/schematics          13.2.5
@angular/cdk                        13.2.5
@angular/cli                        13.2.5
@angular/compiler                   13.2.5
@angular/compiler-cli               13.2.5
@angular/language-service           13.2.5
@angular/material                   13.2.5
@angular/material-moment-adapter    13.2.5
@angular/platform-browser-dynamic   13.2.5
@angular/router                     13.2.5
@schematics/angular                 13.2.5
ng-packagr                          13.2.1
rxjs                                7.5.4
typescript                          4.5.5

尽管 package-lock 文件中有一些指标表明所有版本都匹配,但它们并没有匹配。

这可以通过运行这个或类似的命令有针对性地验证:

npm ls @angular/core

我要感谢 angular 团队帮助我解决这个问题。这是答案和主题的 link。 https://github.com/angular/angular/issues/45265