question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

watch and dev commands compile, prod fails to compile

See original GitHub issue
  • Laravel Mix Version: 0.11.4
  • Node Version: v7.5.0
  • NPM Version: 4.5.0
  • OS: macOS Sierra 10.12.4

Description:

I can compile my assets running npm run watch or npm run dev, but for some reason npm run prod gives me an error.

npm run prod

> @ prod /Users/{user}/Code/{project}
> npm run production


> @ production /Users/{user}/Code/{project}
> cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

 95% emitting                                                                        

 DONE  Compiled successfully in 6168ms                                                                                         8:39:58 AM


undefined:1624
    throw new JS_Parse_Error(message, filename, line, col, pos);
    ^
SyntaxError: Unexpected character '`'
    at JS_Parse_Error.get (eval at <anonymous> (/Users/{user}/Code/{project}node_modules/uglify-js/tools/node.js:27:1), <anonymous>:86:23)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ production: `cross-env 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 'cross-env 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!     cross-env 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! A complete log of this run can be found in:
npm ERR!     /Users/{user}/.npm/_logs/2017-05-03T14_39_58_440Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ prod: `npm run production`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ prod script 'npm run production'.
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!     npm run production
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! A complete log of this run can be found in:
npm ERR!     /Users/{user}/.npm/_logs/2017-05-03T14_39_58_456Z-debug.log

Steps To Reproduce:

webpack.mix.js

const { mix } = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.browserSync({
	proxy: '{site}.dev',
	host: '{site}.dev',
	browser: 'google chrome',
	open: 'external',
	notify: false,
});

mix.scripts([
	// Jquery
	'bower_components/jquery/dist/jquery.js',

	// Foundation
	'bower_components/foundation-sites/js/foundation.core.js',
	'bower_components/foundation-sites/js/foundation.util.*.js',

	// Foundation JS components
	'bower_components/foundation-sites/js/foundation.abide.js',
	'bower_components/foundation-sites/js/foundation.accordion.js',
	'bower_components/foundation-sites/js/foundation.accordionMenu.js',
	'bower_components/foundation-sites/js/foundation.drilldown.js',
	'bower_components/foundation-sites/js/foundation.dropdown.js',
	'bower_components/foundation-sites/js/foundation.dropdownMenu.js',
	'bower_components/foundation-sites/js/foundation.equalizer.js',
	'bower_components/foundation-sites/js/foundation.interchange.js',
	'bower_components/foundation-sites/js/foundation.magellan.js',
	'bower_components/foundation-sites/js/foundation.offcanvas.js',
	'bower_components/foundation-sites/js/foundation.orbit.js',
	'bower_components/foundation-sites/js/foundation.responsiveMenu.js',
	'bower_components/foundation-sites/js/foundation.responsiveToggle.js',
	'bower_components/foundation-sites/js/foundation.reveal.js',
	'bower_components/foundation-sites/js/foundation.slider.js',
	'bower_components/foundation-sites/js/foundation.sticky.js',
	'bower_components/foundation-sites/js/foundation.tabs.js',
	'bower_components/foundation-sites/js/foundation.toggler.js',
	'bower_components/foundation-sites/js/foundation.tooltip.js',
	'bower_components/foundation-sites/js/foundation.zf.responsiveAccordionTabs.js',

	// Vendor
	'bower_components/select2/dist/js/select2.js',
	'bower_components/froala-wysiwyg-editor/js/froala_editor.min.js',
	'bower_components/froala-wysiwyg-editor/js/plugins/image.min.js',
	'bower_components/froala-wysiwyg-editor/js/plugins/image_manager.min.js',
	'bower_components/froala-wysiwyg-editor/js/plugins/link.min.js',
	'bower_components/froala-wysiwyg-editor/js/plugins/lists.min.js',
	'bower_components/froala-wysiwyg-editor/js/plugins/paragraph_format.min.js',
	'bower_components/froala-wysiwyg-editor/js/plugins/quote.min.js',
	'bower_components/sweetalert/dist/sweetalert.min.js',
	'bower_components/dropzone/dist/dropzone.js',
	'bower_components/motion-ui/motion-ui.js',

	// App Scripts
	'resources/assets/js/app.js',
	'resources/assets/js/components/*.js',
	'resources/assets/js/views/*.js'
], 'public/js/app.js');

mix.sass('resources/assets/sass/app.scss', 'public/css');

Run npm run prod and receive the error posted above.

Let me know if there’s any other information I can provide. Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7

github_iconTop GitHub Comments

3reactions
JeffreyWaycommented, May 8, 2017

This seems to be an issue with uglification, but I’m not sure why. Will look into it.

2reactions
snipecommented, May 31, 2017

@JeffreyWay - I pulled down the latest mix release and was still seeing the issue.

@zacksmash - In my case, it was one line (augh! ONE LINE!) of ES6 code. I found it (tediously) by commenting out the scripts() files, line by line, in webpack.mix.json. It took some digging, but it enabled me to find the particular file that was borked, and then my IDE helped isolate the ES6 culprit. It’s a slow and terrible way to figure it out, but might be worth a shot for you. I’d bet money you have a backtick or a hashrocket somewhere there, something easily overlooked.

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm run dev works but watch compiles and errors
It will compile the files but throws and error when it tries to watch the files. npm run dev works just fine. npm...
Read more >
watch:build not working · Issue #12 · keithamus/npm-scripts ...
It seems: nodemon -q -w assets/ --ext '.' --exec 'npm run build' is causing something weird with npm and I get the default...
Read more >
[Solved]-Can't compile VUE.JS with 'npm run dev' and 'npm ...
Coding example for the question Can't compile VUE.JS with 'npm run dev' and 'npm run watch' command-Vue.js.
Read more >
Command failed with exit code 1: npm run build - Netlify fix 2020
Udemy Courses:- 9 React Projects on Udemy - https://bit.ly/2D83M8c- 9 React Projects on Gumroad ...
Read more >
Building for Production
When it is time to deploy your app for production, simply run the vite build command. By default, it uses <root>/index.html as the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found