ys3399gulp执行命令是的错误

2016/12 18 02:12
此文章不得转载,如有需要请联系网站管理员。

一度的温暖,一百度的爱情,来自于ys3399盈丰国际官网的点点滴滴

[13:47:26] Using gulpfile D:\gulpstudyone
[13:47:26] Starting 'scripts'...
ERROR: Can't find config file: .jshintrc

(Can't find config file: .jshintrc)这句找不到.jshintrc,是什么原因呢,下面是我的配置文件:
gulp.task('scripts', function() {
  return gulp.src('src/js/*.js')
    .pipe(jshint('.jshintrc'))
    .pipe(jshint.reporter('default'))
    .pipe(concat('main.js'))
    .pipe(gulp.dest('dist/scripts'))
    .pipe(rename({ suffix: '.min' }))
    .pipe(uglify())
    .pipe(gulp.dest('dist/scripts'))
    .pipe(notify({ message: 'Scripts task complete' }));
});

这个怎么解决,还请高手指点:

这个提示是因为在jshint中指明要调用.jshintrc,这样就需要创建一个.jshintrc的文件,并填入所指定的配置项。使用gulp的jshint可以直接配置或者留空调用默认配置,如:

gulp.task('scripts', function() {
  return gulp.src('src/js/*.js')
    .pipe(jshint())
    .pipe(concat('main.js'))
    .pipe(gulp.dest('dist/scripts'))
    .pipe(rename({ suffix: '.min' }))
    .pipe(uglify())
    .pipe(gulp.dest('dist/scripts'))
    .pipe(notify({ message: 'Scripts task complete' }));
});

或者参考jshint官方例子配置, 例如:

gulp.task('scripts', function() {
  return gulp.src('src/js/*.js')
    .pipe(jshint({
        'undef': true,
        'unused': true
    }))
    .pipe(concat('main.js'))
    .pipe(gulp.dest('dist/scripts'))
    .pipe(rename({ suffix: '.min' }))
    .pipe(uglify())
    .pipe(gulp.dest('dist/scripts'))
    .pipe(notify({ message: 'Scripts task complete' }));
});

感觉不是gulp的问题,是配置jshint的问题。 读取不到.jshintrc 配置文件 看 jshint的配置 http://jshint.com/docs/

JSHint comes with a default set of warnings but it was designed to be very configurable. There are three main ways to configure your copy of JSHint: you can either specify the configuration file manually via the –config flag, use a special file .jshintrc or put your config into your projects package.json file under the jshintConfig property. In case of .jshintrc, JSHint will start looking for this file in the same directory as the file that’s being linted. If not found, it will move one level up the directory tree all the way up to the filesystem root. (Note that if the input comes from stdin, JSHint doesn’t attempt to find a configuration file)

是不是你项目没有配置.jshintrc文件?

(看完/读完)这篇文章有何感想! 来看看ys3399盈丰国际官网是怎么评论的吧!

--转载请注明: ys3399盈丰国际官网_www.ys3399.com_ys3399盈丰国际官网网址 » ys3399gulp执行命令是的错误

发表评论

(必填)