Error In Runtime From Terser During Build --prod

I'm in Angular 11, in my case it gave the same error, but it was my mistake: in angular.json I didn't import the styles and scripts correctly ("styles": [], "scripts": []),always check if the imports of your project are correct, because if it is wrong, this same error will appear.


It seems to be a problem with the recently released version 3.16 of Terser, here's the related issue in Terser and in Terser as a Webpack plugin.

In this VueJS issue they recommended to downgrade it to version 3.14.1. You can do it looking for the line in package.json containing "terser" and pin it as follows:

    "terser": "3.14.1",

For Angular prod build, this fixed it for me:

npm install --save-exact --save [email protected]

As Pietro Saccardi said, by now, it's necessary to fix the Terser version to 3.14.1 in the package.json as follows: "terser": "3.14.1"

Don't use the ^ in the version or it could upgrade to 3.16.