Background

When we create a new NodeJS project, we will inevitably install many dependencies, so we often need to view the source code files of certain dependency packages. However, due to the node_modules directory contains too many files. For performance reasons, searching for the node_modules directory is disabled by default in VSCode. In this case, we will have to expand the node_modules directory tree in sequence to find the files we need. I believe this experience must be very inefficient and annoying. So, how can we customize this default behavior of VSCode?

Goals

Let’s take the CabloyJS project as an example. A new CabloyJS project contains a large number of core modules. If want to Quick Look the source code of the workflow module a-flow, we can do this:

  1. Use the shortcut keys Ctrl+P to open the Quick Open panel

  2. Enter a-flow/pa to quickly locate the file: node_modules/egg-born-module-a-flow/package.json

VSCode Settings

To achieve the above goals, we only need to add the following configuration in the settings.json file:

  1. 1{
  2. 2 "search.exclude": {
  3. 3 "**/node_modules":false
  4. 4 },
  5. 5 "search.useIgnoreFiles":false
  6. 6}
  1. Set **/node_modules to false to disable default behavior and support nodes_modules searching

  2. For many projects, setting **/node_modules to false is enough. So, why do we still need to set search.useIgnoreFiles to false? This is because some projects contain .gitignore file, and node_modules are ignored in the .gitignore file, this mechanism still restricts VSCode’s ability to searching for node_modules directory. Therefore, we need to configure this parameter to ignore this default behavior

Conclusion

In short, setting search.useIgnoreFiles to false is the focus of this article. Because I have consulted a large amount of english community resources to come up with the problem, and I hope it can save your time