开发者问题收集

尝试运行 npm run build 时发生 TypeError

2019-08-01
4980

在我的 angular 应用程序上运行 npm run build 时出现如下错误。我尝试更新 typescript 版本,但没有帮助。请建议可以做什么。有人可以帮忙吗?我读到这是由于循环依赖造成的。我该如何在 node_modules 中解决这些问题?

Object prototype may only be an Object or null: undefined TypeError: Object prototype may only be an Object or null: undefined at setPrototypeOf () at Object.__extends (C:\Users\twdas\Documents\SDTM-POC\bitbucket\clinapps\src\main\CDR-POC\node_modules\tslib\tslib.js:65:9) at C:\Users\twdas\Documents\SDTM-POC\bitbucket\clinapps\src\main\CDR-POC\node_modules@angular\compiler-cli\src\ngtsc\indexer\src\template.js:115:17 at C:\Users\twdas\Documents\SDTM-POC\bitbucket\clinapps\src\main\CDR-POC\node_modules@angular\compiler-cli\src\ngtsc\indexer\src\template.js:314:6 at C:\Users\twdas\Documents\SDTM-POC\bitbucket\clinapps\src\main\CDR-POC\node_modules@angular\compiler-cli\src\ngtsc\indexer\src\template.js:3:17 at Object. (C:\Users\twdas\Documents\SDTM-POC\bitbucket\clinapps\src\main\CDR-POC\node_modules@angular\compiler-cli\src\ngtsc\indexer\src\template.js:9:3) at Module._compile (internal/modules/cjs/loader.js:689:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10) at Module.load (internal/modules/cjs/loader.js:599:32) at tryModuleLoad (internal/modules/cjs/loader.js:538:12) at Function.Module._load (internal/modules/cjs/loader.js:530:3) at Module.require (internal/modules/cjs/loader.js:637:17) at require (internal/modules/cjs/helpers.js:20:18) at C:\Users\twdas\Documents\SDTM-POC\bitbucket\clinapps\src\main\CDR-POC\node_modules@angular\compiler-cli\src\ngtsc\indexer\src\transform.js:20:22 at C:\Users\twdas\Documents\SDTM-POC\bitbucket\clinapps\src\main\CDR-POC\node_modules@angular\compiler-cli\src\ngtsc\indexer\src\transform.js:10:17 at Object. (C:\Users\twdas\Documents\SDTM-POC\bitbucket\clinapps\src\main\CDR-POC\node_modules@angular\compiler-cli\src\ngtsc\indexer\src\transform.js:16:3)

我的 package.json 如下:

{
  "name": "cdr-poc",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --proxy-config proxy-conf.json",
    "build": "ng build",
    "postbuild": "npm run deploy",
    "predeploy": "rimraf ../resources/static/ && mkdirp ../resources/static",
    "deploy": "cpx dist/CDR-POC/** ../resources/static",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.1.10",
    "@angular/common": "^6.1.10",
    "@angular/compiler": "^6.1.10",
    "@angular/core": "^6.1.10",
    "@angular/forms": "^6.1.10",
    "@angular/http": "^6.1.10",
    "@angular/platform-browser": "^6.1.10",
    "@angular/platform-browser-dynamic": "^6.1.10",
    "@angular/router": "^6.1.10",
    "@progress/kendo-angular-buttons": "^4.3.2",
    "@progress/kendo-angular-charts": "^3.5.2",
    "@progress/kendo-angular-dateinputs": "^3.5.2",
    "@progress/kendo-angular-dialog": "^3.10.0",
    "@progress/kendo-angular-dropdowns": "^3.4.1",
    "@progress/kendo-angular-excel-export": "^2.2.0",
    "@progress/kendo-angular-grid": "^3.10.2",
    "@progress/kendo-angular-inputs": "^3.5.0",
    "@progress/kendo-angular-intl": "^1.6.1",
    "@progress/kendo-angular-l10n": "^1.3.0",
    "@progress/kendo-angular-layout": "^3.3.2",
    "@progress/kendo-angular-popup": "^2.5.0",
    "@progress/kendo-data-query": "^1.0.0",
    "@progress/kendo-drawing": "^1.1.2",
    "@progress/kendo-theme-default": "latest",
    "@types/file-saver": "^1.3.1",
    "angular-file-saver": "^1.1.3",
    "bootstrap": "^4.3.1",
    "core-js": "^2.6.1",
    "hammerjs": "^2.0.0",
    "ng-multiselect-dropdown": "^0.2.3",
    "ng6-breadcrumbs": "^1.0.7",
    "ngx-bootstrap": "^3.1.3",
    "ngx-webstorage-service": "^4.0.1",
    "rxjs": "6.3.3",
    "rxjs-compat": "6.3.3",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.12.4",
    "@angular/cli": "^6.1.1",
    "@angular/compiler-cli": "^8.1.3",
    "@angular/language-service": "^6.1.10",
    "@types/jasmine": "^2.8.12",
    "@types/jasminewd2": "^2.0.6",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "cpx": "^1.5.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^4.2.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~1.4.2",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "mkdirp": "^0.5.1",
    "protractor": "^5.4.1",
    "rimraf": "^2.6.2",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1",
    "typescript": "^3.5.3"
  }
}
2个回答

更新到最新发布的版本(8.2.0)。

我的解决方案是升级到:

686832292
Francesco Martini
2019-08-01

我遇到了同样的错误,并设法以一种简单的方式解决了它。

我改变了项目的位置。

改变之后,我去执行已经出现错误的初始命令。

我在 SRC 文件夹中使用 npm install 命令和 b 命令。

当我在上面的文件夹中(即在根文件夹中)运行命令时,它起作用了。

César Augusto
2020-02-13