gulp eslint:TypeError:(0,eslint2.default)不是函数
正在尝试使用gulp运行eslint,并出现此错误。我错过了什么?这是我的gulp eslint:TypeError:(0,eslint2.default)不是函数,gulp,eslint,babeljs,gulp-eslint,Gulp,Eslint,Babeljs,Gulp Eslint,正在尝试使用gulp运行eslint,并出现此错误。我错过了什么?这是我的gulpfile.bable.js文件 import gulp from 'gulp'; import eslint from 'eslint'; const jsFiles = ['*.js', 'src/**/*.js']; gulp.task('lint', () => { gulp.src(jsFiles) .pipe(eslint()) .pipe(eslint.format())
gulpfile.bable.js
文件
import gulp from 'gulp';
import eslint from 'eslint';
const jsFiles = ['*.js', 'src/**/*.js'];
gulp.task('lint', () => {
gulp.src(jsFiles)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
以下是全部错误:
C:\Users\promer\projects\library>gulp lint
[14:50:35] Requiring external module babel-register
[14:50:35] Using gulpfile ~\projects\library\gulpfile.babel.js
[14:50:35] Starting 'lint'...
[14:50:35] 'lint' errored after 10 ms
[14:50:35] TypeError: (0 , _eslint2.default) is not a function
at Gulp.<anonymous> (C:/Users/promer/projects/library/gulpfile.babel.js:8:11)
at module.exports (C:\Users\promer\projects\library\node_modules\orchestrator\lib\runTask.js:34:7)
at Gulp.Orchestrator._runTask (C:\Users\promer\projects\library\node_modules\orchestrator\index.js:273:3)
at Gulp.Orchestrator._runStep (C:\Users\promer\projects\library\node_modules\orchestrator\index.js:214:10)
at Gulp.Orchestrator.start (C:\Users\promer\projects\library\node_modules\orchestrator\index.js:134:8)
at C:\Users\promer\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:129:20
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
at Module.runMain (module.js:606:11)
at run (bootstrap_node.js:394:7)
C:\Users\promer\projects\library>glup lint
[14:50:35]需要外部模块巴别塔寄存器
[14:50:35]使用gulpfile~\projects\library\gulpfile.babel.js
[14:50:35]开始“起毛”。。。
[14:50:35]“lint”在10毫秒后出错
[14:50:35]TypeError:(0,eslint2.default)不是函数
狼吞虎咽。(C:/Users/promer/projects/library/gulpfile.babel.js:8:11)
在module.exports(C:\Users\promer\projects\library\node\u modules\orchestrator\lib\runTask.js:34:7)
位于Gulp.Orchestrator.\u runTask(C:\Users\promer\projects\library\node\u modules\Orchestrator\index.js:273:3)
位于Gulp.Orchestrator.\u runStep(C:\Users\promer\projects\library\node\u modules\Orchestrator\index.js:214:10)
在Gulp.Orchestrator.start(C:\Users\promer\projects\library\node\u modules\Orchestrator\index.js:134:8)
在C:\Users\promer\AppData\Roaming\npm\node\u modules\gulp\bin\gulp.js:129:20
at_combinedTickCallback(内部/流程/下一步勾选js:67:7)
在进程中。_tick回调(内部/process/next_tick.js:98:9)
位于Module.runMain(Module.js:606:11)
运行时(bootstrap_node.js:394:7)
这是一个简单的错误。我差点把问题删掉,但我想其他人可能会犯和我一样的错误。当我安装了gulp eslint时,我实际上是在将常规eslint加载到我的gulp文件中。解决办法是改变这一行
import eslint from 'eslint'
到
import eslint from 'gulp-eslint'