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.

Unexpected token when using import()

See original GitHub issue

I’m submitting a bug report

Webpack Version: 3.3.0

Babel Core Version: 6.25.0

Babel Loader Version: 7.1.1

Please tell us about your environment: Linux

Current behavior: Using import function result in

Module build failed: SyntaxError: Unexpected token, expected {

Expected/desired behavior: Letting webpack handle this.

I read somewhere modules should be disabled for babel, if that’s the case I did not found how. Any insight?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:20 (2 by maintainers)

github_iconTop GitHub Comments

51reactions
felixfbeckercommented, Sep 8, 2017

I have enabled that plugin in .babelrc but still get the error. Any idea?

36reactions
loganfsmythcommented, Jul 23, 2017

You’ll need to enable https://babeljs.io/docs/plugins/syntax-dynamic-import/ The import() syntax is still an experimental proposal, so you need to opt-in to Babel’s support for it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js - SyntaxError: Unexpected token import - Stack Overflow
Seems Node v13.2.0 can't import or import() ES modules as '.js' except when there's a package.json with type: module somewhere above it.
Read more >
Unexpected token import Node.js - Reactgo
In this tutorial, we are going to learn about how to resolve the unexpected token import error in Node.js. When we use es6...
Read more >
Nodejs Uncaught SyntaxError: Unexpected token import
An unexpected token import occurs when an error message appears in the console while running a web application.
Read more >
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 >
Error Unexpected token import in nodejs | Edureka Community
I don't understand what is wrong. Node v5.6.0 NPM v3.10.6 The code: function (exports, require, ... at startup (node.js:140:18) at ...
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