laravel-mix: Error on commands dev and production

Hello πŸ˜ƒ

If i run commands by npm run dev or npm run production, then after some seconds i see this error in console:

ERROR  Failed to compile with 1 errors

 error

/js/app.js from UglifyJs
SyntaxError: Unexpected token: operator (>) [./~/bootstrap/js/src/util.js:8,0][/js/app.js:81,19]

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 28 (10 by maintainers)

Most upvoted comments

@opmind I’d been using that solution: "uglify-js": "git+https://github.com/mishoo/UglifyJS2.git#harmony" but now it doesn’t works for me. I found another solution: "uglify-js": "git://github.com/mishoo/UglifyJS2#harmony-v2.8.22" and then npm i or yarn install

I have solved same problem with import js files from src using #harmony version of ugifyjs: package.json: "uglify-js": "git+https://github.com/mishoo/UglifyJS2.git#harmony" and then npm i or yarn install and resolving node_modules folder with bootstrap in babel-loader section of webpack.config. https://stackoverflow.com/a/43893311

@CasperLaiTW Yea, same problems, thanks πŸ‘

@rorc I think you have to require dist folder

window.jQuery = window.$ = require('jquery');
require('bootstrap/js/dist/util');
require('bootstrap/js/dist/modal');

src files is ES6 code. and config exclude node_modules so webpack don’t compile it.