Cannot use GLOB with JSHint in Windows?

2019-04-29 02:43发布

问题:

I'm doing a PoC of NPM as a build tool (http://blog.keithcirkel.co.uk/how-to-use-npm-as-a-build-tool/). I'm fairly new using NPM. For now, I only have JSHint and Mocha installed. My packagae.json is attached. Now, when I run "npm run lint" in the command line (Windows 7), it gives me an error:

c:\project>npm run list
MyNPMProject@1.0.0 lint c:\project
jshint test/*.js

ERROR: Can't open test/*.js

It works when I change the script "lint": "jshint test/test.js".

Can I use glob with jshint?

Please advise and thank you in advanced.

回答1:

You shouldn't need the glob, just give it the directory and it will scan all js files in there.



回答2:

If you need to use a wildcard that can recurse down into subfolders, such as test/**.js, the basic Windows shell (Command Prompt) doesn't support that, but there are various workarounds/alternatives. See this for more details: https://stackoverflow.com/a/30114333/1593924