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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 07:12:47  来源:igfitidea点击:

jshint Error: Cannot find module 'underscore'

javascriptnpm

提问by realph

My grunttask 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-jshintdirectory is in the /node_modulesdirectory. Is there any reason it can't find the underscoremodule? I've tried running npm installbut 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_modulesfolder and just running npm installagain.

当您有 时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 installagain, 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 updateI test this command and this answer.

你可以使用npm update我测试这个命令和这个答案。