【问题标题】:gulp-eslint: TypeError: (0 , _eslint2.default) is not a functiongulp-eslint: TypeError: (0 , _eslint2.default) 不是函数
【发布时间】:2017-08-13 15:18:23
【问题描述】:

尝试使用 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())
    .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)

【问题讨论】:

    标签: gulp eslint babeljs gulp-eslint


    【解决方案1】:

    这是一个简单的错误。我几乎删除了这个问题,但我认为其他人可能会犯同样的错误。虽然我安装了 gulp-eslint,但实际上我正在将常规 eslint 加载到我的 gulp 文件中。解决方法是更改​​此行

    import eslint from 'eslint'
    

    import eslint from 'gulp-eslint'
    

    【讨论】:

      猜你喜欢
      • 2018-02-10
      • 2016-09-20
      • 1970-01-01
      • 1970-01-01
      • 2019-12-07
      • 2016-03-01
      • 2018-08-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多