gulp-babel: Couldn't find preset "es2015" relative to directory
I use gulp-babel in electron,I have all the dependencies installed. the code is :
function compileJs(cb) {
gulp.src(paths.src.js)
.pipe(babel({
presets: ['es2015', 'stage-2']
}))
.pipe(uglify())
.pipe(gulp.dest(paths.tmp.js))
}
When I was developing, everything was all right. Bug When I packed electron app and run , it throw:
events.js:154 Uncaught Error in plugin 'gulp-babel'
Message:
Couldn't find preset "es2015" relative to directory "/Users/user/WeFlow_workspace/WeFlow-example/src/js"
I don’t know whose fault it is. Can you help me? Thanks.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 9
- Comments: 15 (2 by maintainers)
Have you installed these presets via npm?
The correct example would be to use the npm package names, e.g.:
Hello @littledu, you may want to just resolve the preset location yourself in your build script, example:
In any case, this isn’t actually an issue with gulp-babel, which is just a wrapper. The best places for you to get further help with this are listed in Babel’s README.
@rbatllet yes, I have installed .
npm install babel-preset-es2015 babel-preset-stage-2 --save
after installing this working fine now
@rbatllet Thanks
@panuhorsmalahti I try to transpile from es6 to es5 with gulpv4 and CLIv1.2.2. My gulpfile-task is the following:
I did receive the following error:
Do you have any idea how to solve this issue?
Thanks in advance
For some reason in my case, I got the same error. I installed everything. But it try to find preset-0 relative to the code path which is wrong.
The funny thing. Error disappeared when I created .babelrc file with simple config. ✅
@rbatllet Your suggestion was my first implementation with the same error output! This was the reason why I have found this thread. I have in mind that with gulp version < 4.0.0 this wasn’t a problem at all. But I’m not pretty sure. But why does gulp-babel takes
${global.config.source}
, which in real is /Users/tester/Projects/TestProject/src , as the base/search path for the es2015 preset? This makes no sense at all.