Webpack: vscode causes Unexpected token import

Created on 29 Jul 2016  ·  6Comments  ·  Source: vuejs-templates/webpack

win10 64bit
always
刚init完之后 npm run dev
打开localhost:8080 是可以正常访问的
但是 重启电脑后 npm run dev
打开localhost:8080 就是一片空白 控制台报错
main.js?3479:1 Uncaught SyntaxError: Unexpected token import

Most helpful comment

确认了 原来是是vscode的terminal的问题 用win自带的命令行就没问题了

All 6 comments

如果在init的时候 不选eslint就没事。。。。

确认了 原来是是vscode的terminal的问题 用win自带的命令行就没问题了

I got the same issue, +1

main.js?3479:2 Uncaught SyntaxError: Unexpected token import
(anonymous function) @ app.js:702__webpack_require__ @ app.js:556fn @ app.js:87(anonymous function) @ app.js:587__webpack_require__ @ app.js:556(anonymous function) @ app.js:579(anonymous function) @ app.js:582

果然是vscode的问题, 就连在vscode中右键打开命令提示符来执行都不行,坑了很久。

I got the same issue +1, and I used vscode too.

my solution is add the code into webpack.base.conf.js as below:

      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /node_modules/,
        query: {
          presets: ['es2015']
        }
      },

This looks to be a vscode-specific problem, so it's unfortunately their bug rather than anything wrong with our configuration. @summitxf Thanks for documenting a fix for other users!

Was this page helpful?
0 / 5 - 0 ratings