2016-04-05 121 views
7

我一直在试图使用jshint咕噜模块来验证我的代码,但我总是得到以下错误:grunt-contrib-jshint警告:路径必须是字符串;

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. 

的问题是,即使使用--verbose和-debug,它不显示任何工作的错误,只是“路径必须是一个字符串”,我用JSLint(使用括号)验证文件,它工作得很好,网站也正常工作。

到目前为止我做了什么。

  • Unistalled node.js和节点模块3次(每次尝试不同的东西)。
  • 试图限制我的咕噜任务,只是验证一个非常简单的js文件,也没有工作,这意味着这与代码或我的gruntfile.js无关。
+0

Gulp似乎是构建解决方案的更好选择,它比Grunt更简单快捷; – minimalistix

+2

你正在运行什么版本的节点?我刚刚更新到6,我得到这个错误。 – keepitreal

回答

18

我通过将grunt-contrib-jshint从“0.10.0”更新到“0.12.0”来解决了这个问题。

+2

这固定它与节点v6.2.2,是5.7.0 –

11

我在更新nodev6.4.0后仍然出现错误。

什么帮助我为this comment on github(由杰夫·佩克):

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: "", 
     ... 

这样做,允许grunt jshint完成。

编辑:

好了,我也已经更新node,但不grunt-contrib-jshint,按Zeid Selimovic's answer。这是行之有效的,比以前的解决方法更好

+1

这帮了我。我加了'reporterOutput:“,'和我的咕task任务工作。 – breezy

8

刚刚在节点更新(v6.9.2)后,我得到了问题。

NPM卸载咕噜-的contrib-jshint --save-dev的

NPM安装咕噜-的contrib:它得到了通过以下步骤更新咕噜-的contrib-jshint到最新版本( “1.1.0”)后解决-jshint --save-dev

+0

谢谢你。它为我工作! – adev

+0

谢谢,这对我很有用 –

相关问题