Angular 10 npm 错误 hasBindingPropertyName 不是函数

Angular 10 npm error hasBindingPropertyName is not a function

我在 Jenkins 构建中突然收到此错误,我尝试升级到最新的 Angular 10.1,但即使升级后问题仍未解决。所以我回滚到 Angular 10.0,package.json 下面的依赖项

[09/11/2020 03:26:56.420] - Build:: Compiling @angular/platform-browser-dynamic/testing : es2015 as esm2015 [09/11/2020 03:27:09.120] - Build:: Error: Error on worker #5: TypeError: dir[ioType].hasBindingPropertyName is not a function [09/11/2020 03:27:09.120] - Build:: at Project_folder/node_modules/@angular/compiler/bundles/compiler.umd.js:30061:79 [09/11/2020 03:27:09.120] - Build:: at Array.find () [09/11/2020 03:27:09.120] - Build:: at setAttributeBinding

Package.json

"dependencies": {
    "@angular-devkit/build-angular": "0.1000.4",
    "@angular/animations": "^10.0.7",
    "@angular/common": "^10.0.7",
    "@angular/compiler": "^10.0.7",
    "@angular/core": "^10.0.7",
    "@angular/forms": "^10.0.7",
    "@angular/platform-browser": "^10.0.7",
    "@angular/platform-browser-dynamic": "^10.0.7",
    "@angular/router": "^10.0.7",
    "@ng-idle/core": "^8.0.0-beta.4",
    "@ng-idle/keepalive": "^8.0.0-beta.4",
    "@nguniversal/express-engine": "^9.1.1",
    "@nguniversal/module-map-ngfactory-loader": "^8.1.1",
    "async-exit-hook": "^2.0.1",
    "body-parser": "^1.18.3",
    "cfenv": "^1.2.2",
    "classlist.js": "^1.1.20150312",
    "core-js": "^3.0.0",
    "crypto-js": "3.1.9-1",
    "d3": "^5.9.2",
    "dotenv": "^8.1.0",
    "eureka-js-client": "^4.4.2",
    "file-saver": "^2.0.1",
    "google-maps": "^4.3.2",
    "healthcheck-ping": "^2.0.1",
    "hystrixjs": "^0.2.0",
    "jsnlog": "^2.29.0",
    "json-logic-js": "^1.2.2",
    "jsrsasign": "^8.0.20",
    "memory-cache": "^0.2.0",
    "morgan": "^1.9.1",
    "ng2-cookies": "^1.0.12",
    "ng2-slimscroll": "^2.0.1",
    "ngx-ui-loader": "^9.1.1",
    "ngx-webstorage": "^5.0.0",
    "node-fetch": "^2.3.0",
    "preboot": "^7.0.0",
    "reflect-metadata": "^0.1.13",
    "source-map-support": "^0.5.11",
    "string-to-json": "^0.1.0",
    "text-mask-addons": "^3.8.0",
    "tslib": "^2.0.0",
    "web-animations-js": "^2.3.2",
    "weighted-round-robin": "^2.0.2",
    "zone.js": "~0.10.3"
  },
  "devDependencies": {
    "@angular/cli": "^10.0.4",
    "@angular/compiler-cli": "^10.0.7",
    "@angular/language-service": "^10.0.7",
    "@types/express": "^4.17.7",
    "@types/google-maps": "^3.2.2",
    "@types/jasmine": "^3.5.11",
    "@types/jasminewd2": "^2.0.6",
    "@types/node": "^14.0.23",
    "@types/node-fetch": "^2.5.5",
    "browserstack-local": "^1.3.7",
    "codelyzer": "^6.0.0",
    "cpx": "^1.5.0",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~3.3.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "ng-packagr": "^10.0.0",
    "npm-run-all": "^4.1.5",
    "protractor": "~7.0.0",
    "rimraf": "^3.0.0",
    "ts-loader": "^7.0.5",
    "ts-node": "^8.10.2",
    "tslint": "~6.1.0",
    "typescript": "3.9.7",
    "webpack-bundle-analyzer": "^3.1.0",
    "webpack-cli": "^3.3.12",
    "webpack-node-externals": "^1.7.2"
  }

@angular/compiler 10.1.1.

似乎有问题

这不是该问题的解决方案,但我能够通过将@angular/compiler 和@angular/compile-cli 降级到 10.0 来解决该问题。仅更新 package.json 是不够的。我还需要清理 node_modules 以还原代码。

我采取的导致成功构建的步骤...

  1. 更新package.json
 "dependencies": {
    ...
    "@angular/compiler": "~10.0.3",
    ...
  },
  "devDependencies": {
    ...
    "@angular/compiler-cli": "~10.0.3",
    ...
  }

请注意上面的波浪号 (~) 而不是插入符 (^),这样 npm 就不会自动为您提供 10.1.1。

  1. rm -rf node_modules

  2. npm update && ng build --prod

有时由于 HTML 中的结束标记多或少而发生。 检查 html 模板文件中的最新更改。