spalger / gulp-jshint

JSHint plugin for gulp
MIT License
419 stars 65 forks source link

Error: Cannot find module 'jshint/src/cli' #149

Closed AjayPoshak closed 8 years ago

AjayPoshak commented 8 years ago

While I am trying to use jshint with gulp, I am getting below error: `module.js:442 throw err; ^

Error: Cannot find module 'jshint/src/cli' at Function.Module._resolveFilename (module.js:440:15) at Function.Module._load (module.js:388:25) at Module.require (module.js:468:17) at require (internal/module.js:20:19) at Object. (/Applications/XAMPP/xamppfiles/htdocs/SocialCopsDemo/node_modules/gulp-jshint/src/extract.js:1:79) at Module._compile (module.js:541:32) at Object.Module._extensions..js (module.js:550:10) at Module.load (module.js:458:32) at tryModuleLoad (module.js:417:12) at Function.Module._load (module.js:409:3)`

And my gulpfile.js is as under:

var gulp = require('gulp'),
    cssnano = require('gulp-cssnano'),
    jshint = require('gulp-jshint'),
    uglify = require('gulp-uglify'),
    concat = require('gulp-concat');

gulp.task('styles', function() {
    return gulp.src('styles/custom.css')
        .pipe(rename({
            suffix: '.min'
        }))
        .pipe(cssnano())
        .pipe(gulp.dest('dist/assets/styles'));
});

gulp.task('scripts', function() {
    return gulp.src('js/*.js')
        .pipe(jshint('.jshintrc'))
        .pipe(jshint.reporter('default'))
        .pipe(concat('main.js'))
        .pipe(gulp.dest('js/assets/js'))
        .pipe(rename({
            suffix: '.min'
        }))
        .pipe(uglify())
        .pipe(gulp.dest('dist/assets/js'))
});

gulp.task('clean', function() {
    return del(['dist/assets/js', 'dist/assets/styles']);
});
gulp.task('default', ['clean'], function() {
    gulp.start('styles', 'scripts');
});
pyrsmk commented 8 years ago

+1

mchalapuk commented 8 years ago

Hi, everyone.

The problem originates when installing gulp-jshint via npm:

├── UNMET PEER DEPENDENCY jshint@2.x

which is caused by this line in package.json

A workaround for projects using gulp-jshint is to simply add jshist to dependencies.

npm install --save-dev jshint
spalger commented 8 years ago

Please read the readme

AjayPoshak commented 7 years ago

Thanks, issue has been resolved. npm install --save-dev jshint worked for me.