在Angular 4中生成产品时出错

时间:2018-10-10 12:19:32

标签: javascript angular typescript uglifyjs

当尝试使用以下命令以角度4创建生产版本时:

ng build --prod

ng build --prod --aot=false

我在控制台中遇到以下错误:

chunk {scripts} scripts.d0765ae1a4bba4717f75.bundle.js (scripts) 381 kB [initial] [rendered]
chunk {0} main.20075152b680cf048d04.bundle.js (main) 1.79 MB [initial] [rendered]
chunk {1} polyfills.24783bc638c31078c9bb.bundle.js (polyfills) 60 kB [initial] [rendered]
chunk {2} styles.510fc4debb3c7f60a7cb.bundle.css (styles) 240 kB [initial] [rendered]
chunk {3} vendor.03d0b614f00528c8edb5.bundle.js (vendor) 9.27 MB [initial] [rendered]
chunk {4} inline.31e1fb380eb7cf3d75b1.bundle.js (inline) 798 bytes [entry] [rendered]

ERROR in vendor.03d0b614f00528c8edb5.bundle.js from UglifyJs
undefined
也不会创建

dist文件夹。搜索后,我遇到了一个修复程序,将tsconfig.json中的目标从“ es5”更改为“ es6”。进行此更改后,将在控制台中创建没有错误的内部版本。但是当我运行index.html时,在浏览器控制台中出现以下错误:

     Uncaught TypeError: Cannot convert undefined or null to object
        at Function.getPrototypeOf (<anonymous>)
vendor.62bee233ca73b4fe95c7.bundle.js:1

我尝试了不同的解决方案,但无法解决此错误,项目package.json

{
  "name": "admin-panek",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^4.2.4",
    "@angular/common": "^4.2.4",
    "@angular/compiler": "^4.2.4",
    "@angular/core": "^4.2.4",
    "@angular/forms": "^4.2.4",
    "@angular/http": "^4.2.4",
    "@angular/platform-browser": "^4.2.4",
    "@angular/platform-browser-dynamic": "^4.2.4",
    "@angular/router": "^4.2.4",
    "@asymmetrik/ngx-leaflet": "^2.5.3",
    "@asymmetrik/ngx-leaflet-draw": "^2.7.1",
    "angular-calendar": "^0.22.3",
    "angular2-json2csv": "^1.1.2",
    "bootstrap": "^3.3.7",
    "chart.js": "^2.7.2",
    "core-js": "^2.4.1",
    "file-saver": "^1.3.3",
    "html2canvas": "^1.0.0-alpha.9",
    "html2pdf.js": "^0.8.2",
    "jquery": "^3.2.1",
    "json2csv": "^4.0.0-alpha.0",
    "json2xls": "^0.1.2",
    "jspdf": "^1.3.5",
    "leaflet": "^1.2.0",
    "leaflet-draw": "^1.0.2",
    "ng-lightning": "^2.0.1",
    "ng-socket-io": "^0.2.4",
    "ng2-charts": "^1.6.0",
    "ng2-cloudinary": "^0.9.2",
    "ng2-file-upload": "^1.3.0",
    "ng2-notify-popup": "^0.1.25",
    "ng2-select": "^2.0.0",
    "ngx-bootstrap": "^2.0.3",
    "ngx-filter-pipe": "^1.0.1",
    "ngx-order-pipe": "^1.1.1",
    "ngx-pagination": "^3.1.1",
    "ngx-permissions": "^3.2.3",
    "number-to-words": "^1.2.4",
    "pdfmake": "^0.1.35",
    "rxjs": "^5.4.2",
    "typescript": "^2.3.4",
    "xlsx": "^0.12.2",
    "zone.js": "^0.8.14"
  },
  "devDependencies": {
    "@angular/cli": "^1.7.0-rc.0",
    "@angular/compiler-cli": "^4.2.4",
    "@angular/language-service": "^4.2.4",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/jquery": "^3.2.17",
    "@types/leaflet": "^1.2.6",
    "@types/node": "~6.0.60",
    "codelyzer": "~3.2.0",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~3.2.0",
    "tslint": "~5.7.0",
    "typescript": "~2.8.2"
  }
}

预先感谢您帮助我解决此问题。

1 个答案:

答案 0 :(得分:-2)

能否请您检查您的polyfills.ts文件,并且以下导入语句不作注释。

\Tools\PYTHONPATH Manager\add path\insert