错误:找不到预设“es2015";相对于目录“/Users/username"
尝试使用 gulp-babel 时出现以下错误:
I get the following error when trying to use gulp-babel:
错误:找不到相对于目录的预设es2015""/用户/用户名"
Error: Couldn't find preset "es2015" relative to directory "/Users/username"
我在全局和本地安装了 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'));
});
包.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"
}
我正在使用 node v5.1.0 和 babel v6.4.0
I am using node v5.1.0 and babel v6.4.0
这是终端输出
终端输出
推荐答案
只需要安装babel-preset-es2015
:
CLI 使用示例:
npm install babel-cli babel-preset-es2015
相关文章