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.

UglifyJs SyntaxError: Unexpected token punc

See original GitHub issue

Sorry… yet another one… been trying to apply solutions from existing issues but just can’t seem to get it to work… any help appreciated

npm run dev works fine

npm run production throws this error:

node node_modules/cross-env/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

 95% emitting

 ERROR  Failed to compile with 1 errors                                                                                                                                11:50:52 AM

 error

/js/app.cd39f36f12557ece5895.js from UglifyJs
SyntaxError: Unexpected token punc «,», expected punc «:» [./~/vue-pagination-2/index.js:5,0][/js/app.cd39f36f12557ece5895.js:39293,15]

                                                                    Asset       Size  Chunks                    Chunk Names
  fonts/glyphicons-halflings-regular.eot?f4769f9bdb7466be65088239c12046d1    20.1 kB          [emitted]
  fonts/glyphicons-halflings-regular.svg?89889688147bd7575d6327160d64e760     109 kB          [emitted]
  fonts/glyphicons-halflings-regular.ttf?e18bbf611f2a2e43afc071aa2f4e1512    45.4 kB          [emitted]
 fonts/glyphicons-halflings-regular.woff?fa2772327f55d8198301fdb8bcfc8158    23.4 kB          [emitted]
fonts/glyphicons-halflings-regular.woff2?448c34a56d699c29117adc64c43affeb      18 kB          [emitted]
                                          /js/app.cd39f36f12557ece5895.js    1.55 MB       0  [emitted]  [big]  /js/app
                                      /css/bulma.39f2a655da304184dffc.css     103 kB       0  [emitted]         /js/app
                                        /css/app.39f2a655da304184dffc.css     116 kB       0  [emitted]         /js/app
                                                        mix-manifest.json  167 bytes          [emitted]

npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/Cellar/node/7.5.0/bin/node" "/usr/local/bin/npm" "run" "production"
npm ERR! node v7.5.0
npm ERR! npm  v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! @ production: `node node_modules/cross-env/bin/cross-env.js 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 2
npm ERR!
npm ERR! Failed at the @ production script 'node node_modules/cross-env/bin/cross-env.js 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 node_modules/cross-env/bin/cross-env.js 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.

my .babelrc file

{
  "presets": [
    ["es2015", { "modules": false }]
  ],
  "plugins": ["transform-object-rest-spread"]
}

my package.json

{
  "private": true,
  "scripts": {
    "dev": "node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "hot": "node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "production": "node node_modules/cross-env/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
  "devDependencies": {
    "axios": "^0.15.3",
    "babel-cli": "^6.23.0",
    "babel-plugin-transform-object-rest-spread": "^6.23.0",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-latest": "^6.22.0",
    "bootstrap-sass": "^3.3.7",
    "bulma": "^0.3.1",
    "jquery": "^3.1.1",
    "laravel-mix": "^0.8.1",
    "lodash": "^4.17.4",
    "marker-clusterer-plus": "^2.1.4",
    "vue": "^2.1.10",
    "vue-strap": "github:wffranco/vue-strap",
    "vue-tables-2": "^0.4.33",
    "vue2-google-maps": "^0.5.3"
  },
  "dependencies": {
  }
}

my webpack.mix.js

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

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

mix.combine([
  'resources/assets/mixer/css/bootstrap.min.css',
], 'public/dist/app.css');

if (mix.config.inProduction) {
  mix.version();
} else {
  mix.version();
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
jamestowerscommented, Jun 15, 2017

Came across this just now, I am using the object spread operator but hadn’t included these in my package.json file, adding them in fixed the issue.

"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-latest": "^6.22.0",

I also added this to my .babelrc file:

"presets": [
    ["es2015", { "modules": false }]
  ],
7reactions
vesper8commented, Feb 24, 2017

Well here’s a fix I haven’t seen yet. I told a friend I was having issues with uglifyjs and he suggested I add this to my package.json

"uglify-js": "git+https://github.com/mishoo/UglifyJS2.git#harmony"

And bam! It made that error go away.

I don’t even need those plugins or a .babelrc file now and npm run production works 😃

I don’t fully understand Babel yet… but I do want my code to be compatible with as many devices as I can.

If I don’t have a .babelrc and I don’t have additional babel dependencies installed… will it still make my code compatible with older devices?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uglify SyntaxError: Unexpected token: punc ()) - Stack Overflow
I am trying to use gulp in order to minify a folder containing JS files. However, one of the files has the above...
Read more >
Unexpected token: punc (() - ES6 parsing errors using @babel ...
The error only occurs when running my project in a production environment with UglifyJS enabled. In development, the project run fine.
Read more >
JavaScript : Uglify SyntaxError: Unexpected token: punc ()
JavaScript : Uglify SyntaxError : Unexpected token: punc ()) [ Gift : Animated Search Engine : https://bit.ly/AnimSearch ] JavaScript ...
Read more >
ERROR in build.js from UglifyJs Unexpected token: punc (()
I have developed an application on my local. The client and server run on different ports. The application runs fine on my local...
Read more >
Unexpected token punc «(», expected punc «:» - Laracasts
Hey, I run npm run watch It works fine, when I execute npm run production the following error shows up Unexpected token punc...
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