Already installed babel and presets-es2015
There are corresponding dependencies in package.json
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel-preset-es2015": "^6.24.1",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2"
}
}
gulpfile.js
var gulp = require("gulp");
var babel = require("gulp-babel");
gulp.task("es5", function() {
return gulp.src("es5/test.js")
.pipe(babel({
presets: ["es2015"]
}))
.pipe(gulp.dest("es6"));
});
Directory Structure:
An error is reported when running: Error: Couldn't find preset "es2015" relative to directory "C:\Users\Li\Desktop"
Use: presets: ['es2015'].map(require.resolve) to report: Error: Cannot find module 'es2015'
But I have installed them all, and they are also displayed in package.json
babel-presets-es2015
First check whether it is installed properly.The content in the second pipe is the same as
.babelrc
, only one is neededTry it