TypeError trying to run npm run build

怎甘沉沦 提交于 2021-02-10 12:12:40

问题


Running npm run build on my angular application errors out like below. I tried updating the typescript version but it doesn't help. Please suggest what can be done. Can someone please help? I read that this is due to circular dependencies. How do I resolve those in the 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)

My package.json is as below:

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

回答1:


Update to the latest released versions (8.2.0).

My solution was to upgrade to:

"@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"



回答2:


I had the same error and managed to solve it in a simple way.

I had changed the location of my project.

After the change I went to execute the initial commands where the error already appeared.

I was using the npm install command and the b command inside the SRC folder.

When I ran the commands in a folder above, that is, in the root folder, it worked.



来源:https://stackoverflow.com/questions/57306898/typeerror-trying-to-run-npm-run-build

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!