Reputation: 15372
I'm trying to run a jshint on some JS files, but for some reason am getting an error I don't understand.
//(node v4.2.2)
var jshint = require('jshint');
gulp.task('hint', function(){
return gulp.src('./app/**/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
[11:40:09] Starting 'hint'...
[11:40:09] 'hint' errored after 7.08 ms
[11:40:09] TypeError: jshint is not a function
I've been looking at the releases page and it looks like there were some issues with 2.9.0, but I am getting this same error with both of the release candidates and when reverting to earlier versions. This task was working well a few weeks ago, but it seems like something has broken. Logging jshint
like this, gives me the string below it.
gulp.task('testhint', function(){
console.log(jshint)
});
//{ JSHINT: { [Function] addModule: [Function], data: [Function], jshint: [Circular] } }
I've tried deleting and reinstalling node_modules
as well to no avail. Why is gulp saying that jshint isn't a function?
Upvotes: 1
Views: 998
Reputation: 3435
From the documentation:
NOTE: as of 2.0 jshint must to be installed with gulp-jshint.
Change the statement to:
var jshint = require('gulp-jshint');
Upvotes: 2