When there is a small non-breaking syntax error in a JS file, the production options shows an error without much information:
Whoops! We had trouble minifying "public/js/buy.js". Perhaps you need to use mix.babel() instead?
/home/jvalck/tickets-webapp/node_modules/laravel-mix/src/plugins/CustomTasksPlugin.js:66
throw e;
^
SyntaxError: Unexpected token: name (image)
at JS_Parse_Error.get (eval at <anonymous> (/home/jvalck/tickets-webapp/node_modules/uglify-js/tools/node.js:1:0), <anonymous>:86:23)
npm ERR! Linux 4.8.0-36-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "production"
npm ERR! node v6.11.0
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! @ production: `NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ production script 'NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/jvalck/tickets-webapp/npm-debug.log
This is the line in wabpack.mix.js:
mix.scripts([resourcesScriptDir+'buy.js'], 'public/js/buy.js');
It would be handy if the error message would be more verbose indicating on what line the script failed.
npm run dev doesn't fail), for example an ES6 JS-file.npm run productionSame here ...
At the very top, it does tell you what the problem is:
Whoops! We had trouble minifying "public/js/buy.js". Perhaps you need to use mix.babel() instead
Your buy.js has ES6+ code I imagine. So you need to use mix.babel() instead.
Yeah!!! mix.babel() rules!
It would be nice to be informed which line broke the compilation
Thanks guys! I needed this info too. 馃憤
Thanks! Nice!
Most helpful comment
At the very top, it does tell you what the problem is:
Your buy.js has ES6+ code I imagine. So you need to use mix.babel() instead.