尝试运行npm run build时发生TypeError

时间:2019-08-01 10:24:00

标签: angular typescript npm npm-install

在我的角度应用程序上运行npm run build时出错,如下所示。我尝试更新打字稿版本,但无济于事。请提出可以做什么。有人可以帮忙吗?我读到这是由于循环依赖关系。如何解决node_modules中的问题?

  

Object原型只能是一个Object或为null:undefined TypeError:   对象原型只能是一个对象或null:未定义       在setPrototypeOf()       在Object .__ extends(C:\ Users \ twdas \ Documents \ SDTM-POC \ bitbucket \ clinapps \ src \ main \ CDR-POC \ node_modules \ tslib \ tslib.js:65:9)       在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       在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       在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       在对象。 (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)       在Module._compile(内部/模块/cjs/loader.js:689:30)       在Object.Module._extensions..js(内部/模块/cjs/loader.js:700:10)       在Module.load(internal / modules / cjs / loader.js:599:32)       在tryModuleLoad(内部/模块/cjs/loader.js:538:12)       在Function.Module._load(内部/模块/cjs/loader.js:530:3)       在Module.require(internal / modules / cjs / loader.js:637:17)       在要求时(内部/模块/cjs/helpers.js:20:18)       在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       在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       在对象。 (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 个答案:

答案 0 :(得分:1)

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

我的解决方案是升级到:

"@angular/animations": "~8.2.0",
"@angular/common": "~8.2.0",
"@angular/compiler": "~8.2.0",
"@angular/core": "~8.2.0",
"@angular/forms": "~8.2.0",
"@angular/platform-browser": "~8.2.0",
"@angular/platform-browser-dynamic": "~8.2.0",
"@angular/router": "~8.2.0",
"@angular/cdk": "~8.2.0",
"@angular/cli": "~8.2.0",
"@angular/language-service": "~8.2.0",
"@angular/upgrade": "~8.2.0"

答案 1 :(得分:0)

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

我已经更改了项目的位置。

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

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

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