本文介绍了错误:无法找到预设“es2015”相对于目录“/用户/用户名”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在尝试使用gulp-babel时出现以下错误:
I get the following error when trying to use gulp-babel:
我已经在全局和本地安装了es2015预设,因此看不到为什么会这样将是一个问题。
I have the es2015 preset installed globally and locally so can't see why this would be an issue.
以下是我的gulp设置和package.json。
Below is my gulp set up and package.json.
var babel = require('gulp-babel');
var es2015 = require('babel-preset-es2015');
gulp.task('babel', function() {
return gulp.src('./app/main.js')
.pipe(babel({
presets: [es2015]
}))
.pipe(gulp.dest('dist'));
});
Package.json
Package.json
"devDependencies": {
"babel-preset-es2015": "^6.3.13",
"babel-preset-es2015-node5": "^1.1.1",
"browser-sync": "^2.11.0",
"gulp": "^3.9.0",
"gulp-babel": "^6.1.1",
"gulp-stylus": "^2.2.0"
}
我使用节点v5.1.0和babel v6.4.0
I am using node v5.1.0 and babel v6.4.0
这里是终端输出
terminal output
推荐答案
您只需要安装 babel-preset-es2015
:
CLI使用示例:
npm install babel-cli babel-preset-es2015
这篇关于错误:无法找到预设“es2015”相对于目录“/用户/用户名”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!