Posted at

TypeError: Cannot read property 'minify' of undefined

$ npm run build

に出たエラーについて、デフォルトの設定って楽なだけに思わぬバグが出たりするっていう対策のものです。

!!エラー内容


ERROR Failed to compile with 2 errors 14:59:26

error

js/app.365ab1d3.js from Terser
TypeError: Cannot read property 'minify' of undefined
at minify (/usr/kame/Documents/開発/my-onsen-app/node_modules/terser-webpack-plugin/dist/minify.js:175:23)
at module.exports (/usr/kame/Documents/開発/my-onsen-app/node_modules/terser-webpack-plugin/dist/worker.js:13:40)
at handle (/usr/kame/Documents/開発/my-onsen-app/node_modules/worker-farm/lib/child/index.js:44:8)
at process.<anonymous> (/usr/kame/Documents/開発/my-onsen-app/node_modules/worker-farm/lib/child/index.js:51:3)
at emitTwo (events.js:126:13)
at process.emit (events.js:214:7)
at emit (internal/child_process.js:772:12)
at _combinedTickCallback (internal/process/next_tick.js:141:11)
at process._tickCallback (internal/process/next_tick.js:180:9)

error

js/chunk-vendors.decf2dc1.js from Terser
TypeError: Cannot read property 'minify' of undefined
at minify (/usr/kame/Documents/開発/my-onsen-app/node_modules/terser-webpack-plugin/dist/minify.js:175:23)
at module.exports (/usr/kame/Documents/開発/my-onsen-app/node_modules/terser-webpack-plugin/dist/worker.js:13:40)
at handle (/usr/kame/Documents/開発/my-onsen-app/node_modules/worker-farm/lib/child/index.js:44:8)
at process.<anonymous> (/usr/kame/Documents/開発/my-onsen-app/node_modules/worker-farm/lib/child/index.js:51:3)
at emitTwo (events.js:126:13)
at process.emit (events.js:214:7)
at emit (internal/child_process.js:772:12)
at _combinedTickCallback (internal/process/next_tick.js:141:11)
at process._tickCallback (internal/process/next_tick.js:180:9)

ERROR Build failed with errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-onsen-app@0.1.0 build: `vue-cli-service build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-onsen-app@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /usr/kame/.npm/_logs/2019-02-03T05_59_26_490Z-debug.log

でこれを解決してくれたリンク

https://github.com/vuejs/vue-cli/issues/3407

バグらしいので

$ npm i terser@3.14

コマンドうってとのこと。うって終わって再度

$ npm run build

無事完了!!