npm - Angular 10 npm 错误 hasBindingPropertyName 不是函数

标签 npm angular10

我在 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


包.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.0 来解决该问题。仅更新 package.json 是不够的。我还需要清理 node_modules 以恢复代码。
我采取的步骤导致构建成功......

  • 更新 package.json
  •  "dependencies": {
        ...
        "@angular/compiler": "~10.0.3",
        ...
      },
      "devDependencies": {
        ...
        "@angular/compiler-cli": "~10.0.3",
        ...
      }
    
    注意上面的波浪号 (~) 而不是插入符号 (^),这样 npm 就不会自动给你 10.1.1。
  • rm -rf node_modules
  • npm update && ng build --prod
  • 关于npm - Angular 10 npm 错误 hasBindingPropertyName 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63851241/

    相关文章:

    css - 如何有效地使用 bootstrap-sass?

    node.js - 如果 npm 测试失败,npm posttest 不会触发

    javascript - 如何使用typescript和javascript导入npm包中的js

    typescript - 当 '--module' 为 'none' 时,Visual Studio 2019 无法使用导入、导出或模块扩充

    Angular 10 升级 : Why use @Directive() instead of @Component() for abstract (component) classes?

    angular - 如何显示选定的自定义数据' optionLabel 下拉列表 primeng

    typescript - Angular 10 和 ES2020 中的模块解析因可选链而失败

    node.js - yarn run dev - 跨环境 : Permission denied

    javascript - 如何在安装任何 npm 模块之前运行脚本?

    Angular 10 匹配器 child 不显示 child