简体   繁体   English

grunt-contrib-jshint警告:path必须是一个字符串;

[英]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: 我一直在尝试使用jshint grunt模块来验证我的代码,但我总是得到以下错误:

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. 问题是,即使使用--verbose和-debug,它也没有显示任何可以处理错误的内容,只是“路径必须是一个字符串”,我用JSLint验证了文件(使用括号)并且它工作得很好,网站也行得很好。

what i have done so far. 到目前为止我做了什么。

  • Unistalled node.js and node modules 3 times (trying something different everytime). unistalled node.js和节点模块3次(每次尝试不同的东西)。
  • 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. 试图限制我的grunt任务只是简单地验证一个非常简单的js文件,并且也不起作用,这意味着与代码或我的gruntfile.js无关。

我通过将grunt-contrib-jshint从“0.10.0”更新为“0.12.0”来修复此问题。

I was still getting the error after updating node to v6.4.0 . node更新到v6.4.0后,我仍然收到错误。

What helped me was this comment on github (by Jeff Peck): 是什么帮助了我对github的评论 (Jeff Peck):

I have found the issue to be when the reporterOutput option is set to null. 我发现当reporterOutput选项设置为null时会出现问题。 If you change that option to refer to an empty string, jshint will work as expected: 如果更改该选项以引用空字符串,jshint将按预期工作:

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

Doing that allowed grunt jshint to complete. 这样做可以让grunt jshint完成。

EDIT: 编辑:

Well, I did have updated node , but not grunt-contrib-jshint , as per Zeid Selimovic's answer . 好吧,根据Zeid Selimovic的回答 ,我确实有更新的node ,但不是grunt-contrib-jshint That works and is better than previous workaround 这有效,并且优于以前的解决方法

I got the issue just after updation of node (v6.9.2). 我在更新节点(v6.9.2)后得到了这个问题。 It got resolved after updating grunt-contrib-jshint to the latest version ("1.1.0") by following steps: 通过以下步骤将grunt-contrib-jshint更新到最新版本(“1.1.0”)后得到解决:

npm uninstall grunt-contrib-jshint --save-dev npm卸载grunt-contrib-jshint --save-dev

npm install grunt-contrib-jshint --save-dev npm install grunt-contrib-jshint --save-dev

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM