javascript jshint 错误:找不到模块“下划线”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27251651/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jshint Error: Cannot find module 'underscore'
提问by realph
My grunt
task seems to be running perfectly fine, but every time I run it I'm getting this error:
我的grunt
任务似乎运行得很好,但每次运行它时都会出现此错误:
Loading "jshint.js" tasks...ERROR
>> Error: Cannot find module 'underscore'
Is there any way to find out why this is happening? I can see the /grunt-contrib-jshint
directory is in the /node_modules
directory. Is there any reason it can't find the underscore
module? I've tried running npm install
but I still get the same error when I run grunt.
有没有办法找出为什么会发生这种情况?我可以看到/grunt-contrib-jshint
目录在/node_modules
目录中。有什么原因找不到underscore
模块吗?我试过跑步,npm install
但在运行 grunt 时仍然出现同样的错误。
Any ideas? Any help is appreciated.
有任何想法吗?任何帮助表示赞赏。
回答by jValdron
When you have cannot find module x errors
, one thing that might help sometimes is deleting the whole npm_modules
folder and just running npm install
again.
当您有 时cannot find module x errors
,有时可能会有所帮助的一件事是删除整个npm_modules
文件夹并npm install
再次运行。
Sometimes, on the initial npm install
, it might of failed to get one dependency for a package and it won't try to get it again when you run npm install
again, as it got all of the packages youwanted, just maybe not all the dependencies of those packages.
有时,在最初npm install
,它可能无法获得包的一个依赖项,并且当您npm install
再次运行时它不会尝试再次获取它,因为它获得了您想要的所有包,只是可能不是那些的所有依赖项包。
回答by hjvcghcghchg
you can use npm update
I test this command and this answer.
你可以使用npm update
我测试这个命令和这个答案。