Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

grunt-contrib-jshint warning: path must be a string;

I've been trying to use the jshint grunt module to validate my code, but I always get the following error:

Running "jshint" task
[D] Task source: C:\Coursera\03. Intro Angular JS\conFusion\node_modules\grunt-contrib-jshint\tasks\jshint.js

Running "jshint:all" (jshint) task
[D] Task source: C:\Coursera\03. Intro Angular JS\conFusion\node_modules\grunt-contrib-jshint\tasks\jshint.js
Verifying property jshint.all exists in config...OK
Files: Gruntfile.js, app/scripts/app.js
Options: force=false, reporterOutput=null, jshintrc=".jshintrc", reporter={}
Warning: Path must be a string. Received { toString: [Function], reporter: [Function] } Use --force to continue.

the problem is that even using the --verbose and -debug, it doesnt show anything to work on the error, just "path must be a string", i validated the file with JSLint (using brackets) and it works quite well, website also works fine.

what i have done so far.

  • Unistalled node.js and node modules 3 times (trying something different everytime).
  • tried to limit my grunt task to simply validate a very simple js file, and also doesnt work, it means thats not related to the code or my gruntfile.js.
like image 515
minimalistix Avatar asked Apr 05 '16 19:04

minimalistix


2 Answers

I fixed this issue by updating grunt-contrib-jshint from "0.10.0" to "0.12.0".

like image 102
Zeid Selimovic Avatar answered Oct 21 '22 14:10

Zeid Selimovic


I was still getting the error after updating node to v6.4.0.

What helped me was this comment on github (by Jeff Peck):

I have found the issue to be when the reporterOutput option is set to null. If you change that option to refer to an empty string, jshint will work as expected:

options: {
      jshintrc: '<%= baseDir %>/.jshintrc',
      reporterOutput: "",
      ...

Doing that allowed grunt jshint to complete.

EDIT:

Well, I did have updated node, but not grunt-contrib-jshint, as per Zeid Selimovic's answer. That works and is better than previous workaround

like image 44
Mario Trucco Avatar answered Oct 21 '22 14:10

Mario Trucco