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.

SyntaxError: Unexpected token ... with v4+

See original GitHub issue

Library Affected: workbox-webpack-plugin v4.3.1

Browser & Platform:

  • npm v5.3.0
  • node v8.0.0
  • webpack v4.32.0
  • webpack-cli v3.3.2

Issue or Feature Request Description: Im getting the following error when I run webpack (dev and prod) with the version 4.3.1.

options = { prototype: true, ...options };
                                 ^^^
SyntaxError: Unexpected token ...

After a downgrade to workbox-webpack-plugin v3.6.3 it works as expected. Is this a known issue?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
nico-martincommented, Jun 14, 2019

Ok, that’s strange. Node v8.0.0 throws the SyntaxError: Unexpected token ... Error, but Node v8.10.0 seems to work. I switched multiple times to make sure that’s the problem.

Then I tried your experiment > options = { prototype: true, ...options } and that works with Node 8.10.0 AND Node 8.0.0. So it’s not the spread syntax (that works with both) but something else.

In the end I’m fine with 8.10.0. Thank for your help!

1reaction
jeffposnickcommented, Jun 10, 2019

Hmmm… you mention that you’re using node v8.0.0. Can you confirm that you’re actually on that version, and not something earlier?

As per https://node.green/#ES2015-syntax-spread-syntax-for-iterable-objects, that syntax should be supported going back to node v5.12.0.

I just tried the following experiment, and it worked fine:

$ node -v
v8.16.0

$ node
> options = {1: 2}
{ '1': 2 }
> options = { prototype: true, ...options }
{ '1': 2, prototype: true }
Read more comments on GitHub >

github_iconTop Results From Across the Web

SyntaxError: Unexpected token - JavaScript - MDN Web Docs
The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided.
Read more >
node.js - How to solve error "SyntaxError: Unexpected token '?'"
This will install and use the latest Node.js v14 (14.17.4). If u want to use a different version, change nvm install 14 to...
Read more >
Problem on 4/9: SyntaxError: Unexpected token . | Codecademy
Problem on 4/9: SyntaxError: Unexpected token . I can't seem to figure out what's wrong here. I think it's pretty straightforward and simple...
Read more >
SyntaxError: Unexpected token in JavaScript | bobbyhadz
The error message means that one character was expected, but another character was provided. This is commonly due to typos.
Read more >
JavaScript SyntaxError - Unexpected token - GeeksforGeeks
This JavaScript exceptions unexpected token occur if a specific language construct was expected, but anything else is typed mistakenly.
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