Laravel-mix: Production: show more verbose error

Created on 7 Jul 2017  路  6Comments  路  Source: JeffreyWay/laravel-mix

  • Laravel Mix Version: 1.0.7
  • Node Version: 6.11.0
  • NPM Version: 3.10.10
  • OS: Ubuntu 16.04LTS

Description:

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.

Steps To Reproduce:

  1. Make a small JS-file with a non-breaking syntax error (so that npm run dev doesn't fail), for example an ES6 JS-file.
  2. Run npm run production

Most helpful comment

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.

All 6 comments

Same 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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RomainGoncalves picture RomainGoncalves  路  3Comments

nezaboravi picture nezaboravi  路  3Comments

terion-name picture terion-name  路  3Comments

Bomavi picture Bomavi  路  3Comments

pixieaka picture pixieaka  路  3Comments