Error: Couldn't find preset “es2015” relative to directory “/Users/username”

前端 未结 12 1498
孤城傲影
孤城傲影 2020-12-13 16:59

I get the following error when trying to use gulp-babel:

Error: Couldn\'t find preset \"es2015\" relative to directory \"/Users/username\"

12条回答
  •  感动是毒
    2020-12-13 17:25

    I encountered the same issue and it was because I had a .babelrc file in the root of my directory.

    To fix this add babelrc: false inside the babel options:

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

提交回复
热议问题