Plugin/Preset files are not allowed to export objects, only functions. In [...]/babel-preset-es2015/lib/index.js

987 Views Asked by At

I am trying to get my asset bundling to work with es6 and it wont work. My package.json is:

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

}

My bundle.config.json conatins:

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

My bundle task is:

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/'));
});

And when i try to bundle it throws following error:

[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

There are 1 best solutions below

0
user3241778 On

I solved it myself. The problem was that I had multuple node_modules folders and gulp used the one with the false babel version.