简体   繁体   中英

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

Application successfully builds and ng serve runs. Application will not successfully run/initialize.

There have been no appreciable typescript code changes from when this was working to when failure occurred, so I am focusing on the html template and the tsconfig with context.

The when the html template logic of the generated main.js is run, the execution is failing somewhere/somehow on the second child element elementStart function execution.

在此处输入图像描述

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$1 (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 elements come from a custom build angular library I also build/manage that has been tested with other consuming clients and is working on other projects)

<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
  }
}

Even though the versions specified in the package.json file for all of the angular libraries should have resulted in the same version acorsss the board, there was a version mismatch between the angular/compiler and angular/core(and other critical angular libraries).

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

Even though there were some indicators in the package-lock file that all of the versions matched, they did not.

This can be verified in a targeted way by running this or similar commands:

npm ls @angular/core

I'd like to thank the angular team for helping me out with this. Here is a link to the answers and thread. https://github.com/angular/angular/issues/45265

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM