2017-03-21 22 views
1

試圖運行eslint和gulp並獲取此錯誤。我錯過了什麼?這是我的gulpfile.bable.js文件。gulp-eslint:TypeError:(0,_eslint2.default)不是函數

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) 

回答

2

這是一個簡單的錯誤。我幾乎刪除了這個問題,但我想其他人可能會犯同樣的錯誤。雖然我已經安裝了gulp-eslint,但實際上我正在將常規eslint加載到我的gulp文件中。解決方法是改變這一行

import eslint from 'eslint' 

import eslint from 'gulp-eslint' 
相關問題