【问题标题】:'Unexpected token export' when using gulp / webpackstream / vue使用 gulp / webpackstream / vue 时出现“意外的令牌导出”
【发布时间】:2018-01-16 13:15:12
【问题描述】:

我正在尝试通过 gulp 和 webpack-stream 在我的项目中使用 vue 的模板编译器。设置是这样的:

gulp.task('js', function () {

return gulp.src('./src/js/main.js')
    .pipe(webpackStream(
        module.exports = {
            output : {
                filename: 'bundle.js'
            },
            resolve : {
                alias: {
                    "vue$": "vue/dist/vue.esm.js",
                    // bind to modules;
                    modules: path.join(__dirname, "../node_modules")
                }
            }
        }
    ))
    .on('error', function handleError() {
        this.emit('end'); // Recover from errors
    })
    .pipe(gulp.dest('./js/'));
});

错误信息是这样的:

Uncaught SyntaxError: Unexpected token export

这是由此引起的:

export default Vue$3;

【问题讨论】:

    标签: webpack vue.js gulp es6-modules


    【解决方案1】:

    我相信您应该从您的 webpackStream 参数中删除 module.exports =。它应该是简单的 javascript 文字对象

     .pipe(webpackStream(
        module.exports = {
        ^^^^^^^^^^^^^^^^^
           output : { filename: 'bundle.js' },
      ...
    

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 2021-06-22
      • 2018-11-24
      • 1970-01-01
      • 2018-03-16
      • 1970-01-01
      • 2021-04-13
      • 2020-12-23
      • 1970-01-01
      • 2020-12-30
      相关资源
      最近更新 更多