ng build --prod引发异常

时间:2019-02-07 06:55:42

标签: angular angular-cli

在创建生产版本时出现错误

ERROR in common.162374785956ac8f24a6.js from Terser
TypeError: Cannot read property 'minify' of undefined
    at minify (C:\path\node_modules\terser-webpack-plugin\dist\minify.js:162:59)
    at module.exports (C:\path\node_modules\terser-webpack-plugin\dist\worker.js:16:41)
    at handle (C:\path\node_modules\worker-farm\lib\child\index.js:44:8)
    at process. (C:\path\node_modules\worker-farm\lib\child\index.js:51:3)
    at process.emit (events.js:182:13)
    at emit (internal/child_process.js:812:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

以下Angular-CLI版本详细信息:

$ ng --version

Angular CLI: 7.1.4
Node: 10.13.0
OS: win32 x64
Angular: 7.1.4

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.11.4
@angular-devkit/build-angular     0.11.4
@angular-devkit/build-optimizer   0.11.4
@angular-devkit/build-webpack     0.11.4
@angular-devkit/core              7.1.4
@angular-devkit/schematics        7.1.4
@ngtools/webpack                  7.1.4
@schematics/angular               7.1.4
@schematics/update                0.11.4
rxjs                              6.3.3
typescript                        3.1.6
webpack                           4.23.1

请帮助。预先感谢。

1 个答案:

答案 0 :(得分:2)

对于terser 3.16的最新最新版本,here报告了一个错误,在此之前,您可以使用解决方法。

安装兼容的terser 3.14版本以解决此问题

npm i terser@3.14