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.

webpack.config.babel.js Unexpected token import

See original GitHub issue

i’d appretiate a double check in webpack.config.js. i’m not a seasoned webpacker and it seems it has this import / loader issues.

webpack.config.babel.js:1
(function (exports, require, module, __filename, __dirname) { import fs from 'fs';
                                                              ^^^^^^
SyntaxError: Unexpected token import

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
sbussardcommented, Feb 22, 2017

This .babelrc file will do it

{
  "presets": [
    ["es2015", {"modules": false}],
    "react",
    "stage-2"
  ],
  "plugins": [
    ["babel-root-import", {"rootPathSuffix": "src"}],
    ["transform-runtime", {"polyfill": false, "regenerator": true}]
  ]
}

this is what triggers it ["es2015", {"modules": false}]

0reactions
developitcommented, Feb 23, 2017

Right, would be a webpack 2 thing. That’s why this project uses webpack 1 😛

Read more comments on GitHub >

github_iconTop Results From Across the Web

`Unexpected token import` in `webpack.config.babel.js` when ...
I'm guessing this is because babel-loader doesn't act on webpack.config.babel.js , and so it's not recognising the import keyword. The error ...
Read more >
Unexpected token when using import() · Issue #493 - GitHub
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 ...
Read more >
webpack/webpack - Gitter
So I have import loadCurrentUser from 'accounts/actions' and accounts is the alias. ... exceptions like "Unexpected token import" on webpack.config.babel.js ...
Read more >
Unexpected token import` in `webpack.config.babel.js` when ...
You have created a webpack.config.js and when tying to execute webpack you are getting above error. Cause your webpack config file need to...
Read more >
Javascript – Error in using 'import' in webpack.config.babel.js
It seems like this occurs because it can't read import or webpack doesn't support import . I tried to use babel-register but it...
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