Gulp Error: Cannot find module 'jshint/src/cli'
Asked Answered
M

6

119

So I've got a fresh install of El Capitan and I'm giving these task runners another go.

I'm following sitepoint's An introduction to Gulp.js, but I'm stuck on step four, when I try to run gulp jshint I get "Error: Cannot find module 'jshint/src/cli'"

I've no idea what's causing this, which is why I'm asking here. Below are a couple of screen grabs to help with the issue.

Terminal error when running gulp jshint

Folder structer for gulp project

As always, I'm eternally grateful for any advice.

Maris answered 29/11, 2015 at 15:38 Comment(7)
Is jshint installed?Forelock
Yes, it is. I even reinstalled it to be sure and I'm still getting the same error.Maris
How did you installed it? Needs to be installed like this: npm install jshint gulp-jshint --save-dev from the root of your node app.Forelock
I used npm install gulp-jshint --save-dev as stated in step four of the tutorial I originally linked to. It would have been within the test folder directory, I assume this is where it should be installed, yes?Maris
delete folder gulp-jshint try reinstall.Miran
@Maris did you also do npm install jshint?Maintenon
I used npm install gulp-jshint --save-dev is that different to npm install jshint?Maris
G
330

You need to install jshint as well, that will sort out the issue.

> npm install --save-dev jshint gulp-jshint
Grisaille answered 1/12, 2015 at 0:44 Comment(2)
I just ran into the same problem. I think the developers made a change to the structure of gulp-jshint in the latest version which has caused this problem (if you see github.com/spalger/gulp-jshint/issues/131). I noticed a peer dependency warning when I installed gulp-jshint.Command
when typing npm install --save-dev jshint gulp-jshint it works fine with meGate
M
27

It turns out I need to use npm install --save-dev jshint gulp-jshint instead of npm install gulp-jshint --save-dev as the tutorial stated. Discussion around this was found at https://github.com/spalger/gulp-jshint/issues/131 with massive thanks to @user3042437 for suppling the link.

Maris answered 13/12, 2015 at 21:15 Comment(0)
I
0

If you still get the error after you put in the correct syntax above, (npm install --save-dev jshint gulp-jshint), which works.

Before you run the install again, go into your package.json file and remove the lines for jshint and gulp-jshint before you run the install, make sure you edit you package.json to remove the lines that call jshint and gulp-jshint, otherwise, the error will persist.

Izard answered 10/1, 2018 at 16:22 Comment(0)
C
-1

Sometimes the order of the phrasing does matter. I found out that this npm install --save-dev jshint gulp-jshint does not work but this npm install jshint gulp-jshint --save works

Coagulum answered 4/5, 2017 at 13:33 Comment(0)
H
-1

Here you target jshint, which you probably didn't install. (You do this in gulp.task('jshint', function() {.)

Try this:

gulp.task('gulp-jshint', function() {

This matches the way you required it.

var jshint = require('gulp-jshint');
Hamrnand answered 7/6, 2017 at 21:37 Comment(0)
S
-2

There is a temporary solution for bypassing this error. Even this temporary solution will also work properly, if in case you don't want to use jshint.js file in you application anywhere.

  1. Go to your gulpfile.js file.
  2. Comment the code in line number 4.

    var jshint = require('gulp-jshint');
    
  3. Now, run gulp command in your terminal. Your server will be up.

Shove answered 9/5, 2018 at 13:34 Comment(1)
This answer does not fix the root problem, which I think should be the focus of an answer on SO.Conwell

© 2022 - 2024 — McMap. All rights reserved.