Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot build prod after angular 5 to 7 update, terser error [duplicate]

I had an Angular-cli project with Angular 5.2. that I updated to Angular 7.2.3. Everything is ok, ng serve, ng test, but when I want to ng build --prod I get errors

I followed the guide (https://update.angular.io/) step by step

Here are the errors :

ERROR in runtime.82c6613acef8f7246fe8.js from Terser
TypeError: Cannot read property 'minify' of undefined
    at minify (/Users/nicolasgarin/Desktop/afreecom/front/node_modules/terser-webpack-plugin/dist/minify.js:175:23)
    at module.exports (/Users/nicolasgarin/Desktop/afreecom/front/node_modules/terser-webpack-plugin/dist/worker.js:13:40)
    at handle (/Users/nicolasgarin/Desktop/afreecom/front/node_modules/worker-farm/lib/child/index.js:44:8)
    at process.<anonymous> (/Users/nicolasgarin/Desktop/afreecom/front/node_modules/worker-farm/lib/child/index.js:51:3)
    at process.emit (events.js:180:13)
    at emit (internal/child_process.js:783:12)
    at process._tickCallback (internal/process/next_tick.js:178:19)
ERROR in main.ae88265d57a522e8fef6.js from Terser
TypeError: Cannot read property 'minify' of undefined
    at minify (/Users/nicolasgarin/Desktop/afreecom/front/node_modules/terser-webpack-plugin/dist/minify.js:175:23)
    at module.exports (/Users/nicolasgarin/Desktop/afreecom/front/node_modules/terser-webpack-plugin/dist/worker.js:13:40)
    at handle (/Users/nicolasgarin/Desktop/afreecom/front/node_modules/worker-farm/lib/child/index.js:44:8)
    at process.<anonymous> (/Users/nicolasgarin/Desktop/afreecom/front/node_modules/worker-farm/lib/child/index.js:51:3)
    at process.emit (events.js:180:13)
    at emit (internal/child_process.js:783:12)
    at process._tickCallback (internal/process/next_tick.js:178:19)
ERROR in polyfills.93cd0d5603ed4cb47cce.js from Terser
TypeError: Cannot read property 'minify' of undefined
    at minify (/Users/nicolasgarin/Desktop/afreecom/front/node_modules/terser-webpack-plugin/dist/minify.js:175:23)
    at module.exports (/Users/nicolasgarin/Desktop/afreecom/front/node_modules/terser-webpack-plugin/dist/worker.js:13:40)
    at handle (/Users/nicolasgarin/Desktop/afreecom/front/node_modules/worker-farm/lib/child/index.js:44:8)
    at process.<anonymous> (/Users/nicolasgarin/Desktop/afreecom/front/node_modules/worker-farm/lib/child/index.js:51:3)
    at process.emit (events.js:180:13)
    at emit (internal/child_process.js:783:12)
    at process._tickCallback (internal/process/next_tick.js:178:19)
ERROR in styles.dcc46c6ff0d6be4a76ad.js from Terser
TypeError: Cannot read property 'minify' of undefined
    at minify (/Users/nicolasgarin/Desktop/afreecom/front/node_modules/terser-webpack-plugin/dist/minify.js:175:23)
    at module.exports (/Users/nicolasgarin/Desktop/afreecom/front/node_modules/terser-webpack-plugin/dist/worker.js:13:40)
    at handle (/Users/nicolasgarin/Desktop/afreecom/front/node_modules/worker-farm/lib/child/index.js:44:8)
    at process.<anonymous> (/Users/nicolasgarin/Desktop/afreecom/front/node_modules/worker-farm/lib/child/index.js:51:3)
    at process.emit (events.js:180:13)
    at emit (internal/child_process.js:783:12)
    at process._tickCallback (internal/process/next_tick.js:178:19)

I have no clue about what's wrong and google didn't helped me neither

like image 510
Nicolas Garin Avatar asked Feb 02 '19 22:02

Nicolas Garin


People also ask

Why is angular material update not working?

Angular material update: It gives errors in some versions of angular material when running update scripts because of the update scripts do not run smoothly in some versions. What I did is updating material after getting everything done. So when I finish with all other updates, I just ran ng update @angular/material.

Is it possible to use resolve() function in angular 9?

It’s not used after Angular 9. Inputs with number types now can not use change events, it should be switched to input event instead. Unfortunately migrate scripts won’t do this automatically for you. Resolve function can not be called with empty parameters in promise objects, it should be called at least with true.

Why angular does not work with typescript?

Some versions of Angular might not work with latest version of typescript. You will need to downgrade typescript version in that case. Also be careful about other possible incompatible packages.

Is it possible to use change event in angular 9?

It’s not used after Angular 9. Inputs with number types now can not use change events, it should be switched to input event instead. Unfortunately migrate scripts won’t do this automatically for you.


1 Answers

That is a problem with the current version of terser, by now, you should set the version to 3.14.1 in your package.json as follows: "terser": "3.14.1",

If you have "terser": "^3.14.1", by sure to remove the ^.

like image 166
Daniel Avatar answered Sep 27 '22 00:09

Daniel