Cannot assign to read only property 'warnings' of true

Earlier this week I ran a new grunt script that bundles and minimizes JavaScript. I copied the grunt configuration from another project because I am lazy. When I ran the uglify process I received the following error:

Cannot assign to read only property 'warnings' of true

Cannot assign to read only property warnings of true

Turns out the code I copied was a little out of date.

   uglify: {     options: {      compress: true     },     //define uglify configs      }

The problem is the uglify node module no longer supports the compress true value. Instead you should set it to an empty JavaScript object. The reason is uglify has many options you can pass to the compressor to control how the process optimizes code. A true value would not be valid enough. So an empty object lets the grunt uglify plugin to use the default settings. You can pass false to turn compression off.

   uglify: {     options: {      compress: {}     },     //define uglify configs     }

To read more about the uglify compressor options reference this page.

After making this change you should be able to run uglify via grunt without any issues.

Share This Article With Your Friends!

Googles Ads Facebook Pixel Bing Pixel LinkedIn Pixel