如何解决不允许插件/预设文件导出对象---使用gulp-babel问题
我正在练习JavaScript,现在设置我的本地环境。 我想将ES6代码转换为ES5,所以请使用gulp-babel。
当我在根目录下命令'gulp'时,错误消息会像这样弹出:
[16:49:03] Using gulpfile ~/Programming/JavaScript/lj/gulpfile.js
[16:49:03] Starting 'default'...
[16:49:04] 'default' errored after 594 ms
[16:49:04] Error in plugin "gulp-babel"
Message:
Plugin/Preset files are not allowed to export objects,only functions. In /Users/chaewonkang/Programming/JavaScript/lj/node_modules/babel-preset-es2015/lib/index.js
我的package.json文件是:
{
2 "name": "lj",3 "version": "1.0.0",4 "description": "",5 "main": "index.js",6 "scripts": {
7 "test": "echo \"Error: no test specified\" && exit 1"
8 },9 "repository": {
10 "type": "git",11 "url": "git+https://github.com/chaewonkang/learning_javascript.git "
12 },13 "author": "",14 "license": "ISC",15 "bugs": {
16 "url": "https://github.com/chaewonkang/learning_javascript/issues"
17 },18 "homepage": "https://github.com/chaewonkang/learning_javascript#read me",19 "dependencies": {
20 "@babel/core": "^7.11.4",21 "@babel/preset-env": "^7.11.0",22 "babel-core": "^6.26.3",23 "underscore": "^1.10.2"
24 },25 "devDependencies": {
26 "babel-loader": "^7.1.5",27 "babel-preset-es2015": "^6.24.1",28 "gulp": "^4.0.2",29 "gulp-babel": "^7.0.0",30 "webpack": "^3.10.0"
31 }
32 }
我的gulpfile.js是:
1 const gulp = require('gulp');
2 const babel = require('gulp-babel');
3
4 /* we will write gulp dependencies here */
5
6 gulp.task('default',function() {
7 /* we will write gulp works here */
8
9 /* node source */
10 gulp.src("es6/**/*.js")
11 .pipe(babel())
12 .pipe(gulp.dest("dist"));
13 /* browser source */
14 gulp.src("public/es6/**/*.js")
15 .pipe(babel())
16 .pipe(gulp.dest("public/dist"));
17 }); ```
Now stuck in installing and uninstalling dependencies. How can I solve this problem? Thank you in advance!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。