0

I am trying to convert the ES6 code to simple JS, using babel in gulp. Running the below code I am getting [Error in Plugin "gulp-babel"] with Message: [Plugin/Preset files are not allowed to export objects, only functions.]

  var gulp = require('gulp');
  var babel = require('gulp-babel');
  gulp.task('scripts',function(){
      return gulp.src(['src/scripts/app.js'])
      .pipe(babel({presets:['es2015']}))
      .pipe(gulp.dest('build/scripts/'))
  });

src/scripts/app.js

const hello = (name) => {
    return `hello ${name}`; 
};

Guiding me to convert the ES6 code to vanilla JS would be most appreciated.

1
  • The code worked for the following version combinations "devDependencies": { "@babel/core": "^7.0.0", "@babel/preset-env": "^7.2.3", "gulp": "^4.0.0", "gulp-babel": "^8.0.0" } Commented Jan 8, 2019 at 9:59

1 Answer 1

3

You're probably using Babel 7, and your preset is not compatible with it. You should install and use { presets: ["@babel/preset-env"] }.

Sign up to request clarification or add additional context in comments.

2 Comments

yes got it. it is due to the mismatched versions of the dependencies. thank you!
also changed the code as mentioned by @TheDancingCode

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.