How To Deal With Node_modules In PhpStorm

- 1 answer

I have been setting up my development environment for my Laravel/AngularJS project. My IDE is JetBrains PhpStorm. I am wondering what are the best practices for configuring the IDE to deal with the node_modules (or bower_components or vendor for my PHP) folder, so that:

  1. It is not included in the code inspection as far as the modules' internal code is concerned.
  2. It is included in the code inspection as far as references in my own code to the modules is concerned.
  3. It is included in Autocomplete or Code Navigation (Ctrl+click on methods)

To make it more clear: I want to be able to Ctrl+click on methods of my node modules and be redirected to the source code of these modules. I also want to be warned if I write a node module method wrong, or if it does not exist. Also autocomplete a method, when I press Ctrl+Space. But I don't want the internal code of my node modules to be included in code inspection, because it takes a lot of time to inspect all the modules, and they are supposed to be ok, so I don't need to inspect them.

I already tried two solutions:

  • Marking the folders as excluded: This does not work because the folders are totally excluded from the project and redirection and inspection does not work at all
  • Creating a specific Scope (in PhpStorm Settings), that includes all files except the node_modules folder, to use when I manually run Code Inspection: It is impossible to exclude the node_modules folder, because my IDE recognizes it as a module "I think" (it has [webapp] next to it in the Project explorer). I could however exclude bower_components and vendor.

Regardless my tries, what is the best way to deal with it?



As it's mentioned in help, PhpStorm auto-excludes node_modules folder from indexing for better performance, adding the direct dependencies listed in package.json to javascript libraries for completion, etc. So the best way to handle node_modules is relying on the IDE default procedures