Winnemucca
Winnemucca

Reputation: 3458

setting up babel with gulp

I am working though using babel with gulp. The set up seemed pretty straightforward. I set up a source folder and created a app.js file

http://babeljs.io/docs/setup/#gulp

var gulp = require("gulp");
var babel = require("gulp-babel");

gulp.task("default", function () {
  return gulp.src("src/app.js")
    .pipe(babel())
    .pipe(gulp.dest("dist"));
});

However, I am getting errors in the json5.js file from my node modules for various lines when I run gulp.

Error while parsing JSON - Unexpected ''
at JSON5.parse.error (/Users/steven/projects/es6/node_modules/json5/lib/json5.js:50:25)
at JSON5.parse.word (/Users/steven/projects/es6/node_modules/json5/lib/json5.js:378:13)
at JSON5.parse.value (/Users/steven/projects/es6/node_modules/json5/lib/json5.js:478:56)
at Object.parse (/Users/steven/projects/es6/node_modules/json5/lib/json5.js:491:18)
at OptionManager.addConfig (/Users/steven/projects/es6/node_modules/babel-core/lib/transf

I found my way to the files and cannot understand why some of these are causing errors.

ex:

default:
        return ch >= '0' && ch <= '9' ? number() : word();
    }

I tried to change the quotes to double just to test but am still getting the same error. Not sure what would cause this. Any help or direction would be greatly appreciated.

Upvotes: 0

Views: 513

Answers (1)

Elger van Boxtel
Elger van Boxtel

Reputation: 1060

I had the same problem yesterday and I resolved it by adding a .babelrc file in the root of my project.

The .babelrc should contain the following content:

{
  "presets": "es2015"
}

This should allow the OptionManager.addConfig to find your .babelrc file and your problem should be fixed ;-)

Upvotes: 1

Related Questions