简体   繁体   English

如何在node_modules中调试文件

[英]how to debug a file in node_modules

I'm new to node and am playing around with SailsJS. 我是Node的新手,并且正在使用SailsJS。 I found what I think is a bug (reported it), but I wanted to have ago at debuging it myself. 我发现我认为是一个错误(已报告),但是我想在自己调试之前就拥有它。

I located the file that I need to investigate in the node_modules folder. 我在node_modules文件夹中找到了需要调查的文件。

I tried putting a console.log in it to ensure I had the right one. 我尝试将console.log放入其中,以确保我拥有正确的控制台。 Nothing happened. 没啥事儿。

So I tried placing log statements in several other files in node_modules that are at the top of the dependency tree. 因此,我尝试将日志语句放置在依赖关系树顶部的node_modules的其他几个文件中。 Nothing is printing out. 什么都没打印出来。

Do I need to do something to refresh the cache make this work? 我是否需要做一些刷新缓存的工作才能使它正常工作? OR am I going about this in completely the wrong way! 还是我完全以错误的方式来解决这个问题!

Usually, if you think that an external module has a bug, the best approach is to clone it and write a test that shows which is the offending set of inputs. 通常,如果您认为某个外部模块存在错误,则最好的方法是克隆它并编写测试以表明哪个是有害的输入集。 SailJS is available on GitHub, so you can freely and easily contribute with a merge request if you find that you are right. SailJS在GitHub上可用,因此如果您发现自己是对的,则可以自由,轻松地为合并请求做出贡献。 This way, you can adopt the same approach used by the project to test the code (as an example, using mocha). 这样,您可以采用项目所使用的相同方法来测试代码(例如,使用mocha)。 In case the merge request will be accepted, while waiting for a new release on npm you can refer to your remote copy by means of the package.json file. 如果合并请求将被接受,则在等待npm上的新版本时,可以通过package.json文件引用远程副本。

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

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