SyntaxError: ‘import’ and ‘export’ may appear only with ‘sourceType: module’ – Gulp

Older versions of Babel came with everything out of the box. The newer version requires you install whichever plugins your setup needs. First, you’ll need to install the ES2015 preset.

npm install babel-preset-es2015 --save-dev

Next, you need to tell babelify to use the preset you installed.

return browserify({ ... })
  .transform(babelify.configure({
    presets: ["es2015"]
  }))
  ...

Source

Leave a Comment