插件/预设文件不允许导出对象,只能导出功能。在[/babel-preset-es2015/lib/index.js中

时间:2019-01-12 20:44:45

标签: gulp babeljs gulp-babel

我正在尝试将资产捆绑在一起以与es6一起使用,但它将无法正常工作。我的package.json是:

"devDependencies": {
"babel-preset-es2015": "^6.6.0",
"del": "^2.2.0",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2"

}

我的bundle.config.json别名:

options: {
    uglify: ['production'], // uglify the resulting bundle in prod
    rev: ['production'], // rev the resulting bundle in prod
    transforms: {
      scripts: lazypipe().pipe(babel, {
        presets: ['es2015']
      }
      )
    }
  }

我的捆绑包任务是:

var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var sass = require('gulp-sass');
var bundle = require('gulp-bundle-assets');
var del = require('del');
[...]
gulp.task('bundle', function() {
del([
    './atlas3src/public/assets/bundles/**/*',
]);
return gulp.src('./bundle.config.js')
    .pipe(bundle())
    .pipe(bundle.results({
        dest: './atlas3src/public/assets/',
        pathPrefix: '/assets/bundles/'
    }))
    .pipe(gulp.dest('./atlas3src/public/assets/bundles/'));
});

当我尝试捆绑时会引发以下错误:

[20:30:33] Error in plugin "gulp-babel"
Message:
Plugin/Preset files are not allowed to export objects, only functions. In /home/ubuntu/workspace/node_modules/babel-preset-es2015/lib/index.js

1 个答案:

答案 0 :(得分:0)

我自己解决了。问题是我有多个node_modules文件夹,而gulp使用的是错误的babel版本。