【问题标题】:Webpack + Babel + ES 2015 Unexpected token import on browserWebpack + Babel + ES 2015 浏览器上的意外令牌导入
【发布时间】:2016-07-13 15:54:02
【问题描述】:

虽然这里已经提出了这个问题: webpack + babel - react, unexpected token 'import'

但我再次问这个问题,因为我无法使用提供的答案来解决。

我无法让这个工作。任何关于指出这里有什么问题的帮助表示赞赏。我是第一次用 es-2015 设置 webpack。

它仍然抛出同样的错误 Unexpected token import on browser

我的 babelrc 文件

{
    "presets": ["es2015"]
}

webpack.config.js:

module.exports = {
entry: './app.js',
output: {
    path: './bin',
    filename: 'app.bundle.js'
},
module: {
    loader: [
        {
            test: /\.js$/,
            exclude: /node_modules/,
            loader: 'babel',
            query: {
              presets: ['es2015']
            }
        }
    ]
}
};

【问题讨论】:

    标签: ecmascript-6 webpack babeljs


    【解决方案1】:

    您的配置看起来不错。您是否在 Node/NPM 上使用最新版本?升级到 Node 6.3 & npm 3.10.3 和 rm -rf node_modules | npm i

    由于 VirtualBox 中的错误,Vagrant 有时也会导致此问题。解决方案是在您的 nginx 配置中设置 sendfile off;,如果您使用 Apache,则设置为 EnableSendfile Off

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-03-07
      • 2017-03-17
      • 2017-05-08
      • 2019-09-16
      • 2016-07-10
      • 2017-05-20
      • 2017-12-10
      相关资源
      最近更新 更多