How to fix 'TypeError: Cannot read property 'minify' of undefined' in terser-webpack-plugin when building a new Vue CLI 3 project?

  • A+

I created a new project with the Vue CLI 3 (configured: babel, pwa, eslint, mocha). Running the test environment using npm run serve works just fine, but I can't build the project for production.

I installed the current version of the Vue CLI 3 and tried creating projects with different configurations. I get the following error message when building the project.

js/app.bb3f3c6e.js from Terser TypeError: Cannot read property 'minify' of undefined     at minify (/Users/.../untitled/node_modules/terser-webpack-plugin/dist/minify.js:176:23)     at module.exports (/Users/.../untitled/node_modules/terser-webpack-plugin/dist/worker.js:13:40)     at handle (/Users/.../untitled/node_modules/worker-farm/lib/child/index.js:44:8)     at process.<anonymous> (/Users/.../untitled-adventure/node_modules/worker-farm/lib/child/index.js:51:3)     at process.emit (events.js:188:13)     at emit (internal/child_process.js:828:12)     at processTicksAndRejections (internal/process/next_tick.js:76:17) 


This is a known issue (vuejs/vue-cli#3407) with the terser 3.16 dependency.

The workaround is to install 3.14 for now:

npm i terser@3.14 


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: