Custom Search - exclude all node_modules recusively

Answered

Hi

I would like to create a custom search in Find In Path , to exclude all node_modules recursively

I coudnt find an easy way , . The only way I can see , is going inside the project tree and excluding each node_module folder one by one.

This is a very hard way of doing it.

I would like a clever way of doing it . filter all folders called node_module recusively.

What pattern can I use.

Thanks.

10 comments
Comment actions Permalink

Mark directory as/Excluded in folder right-click menu excludes the folder recursively - all files/subfolders of excluded folder are excluded.

Note also that you can create a custom scope with node_modules folder excluded recursively (Settings/Preferences | Appearance & Behavior | Scopes) and use this scope when searching in Find In Path

0
Comment actions Permalink

Hi Elena

I know what you said , this doesnt help me.

My problem is that I have a very large tree with many folders and sub folders and each one contains a node_module folder. I do not want to go and exclude each node_module folder seperately. I would like to just set the pattern that it ignores all node_module folders recursively

0
Comment actions Permalink

can't you create the corresponding scope then? Like !file[your_project]:*node_modules//*

0
Comment actions Permalink

Hi Elena

This is exactly what I was looking for 

Thanks thats great.

0
Comment actions Permalink

Doesn't work.... never have I ever had a software that was such a pain to search. A million features, but the important ones, don't work. I wish they'd stop spending time on features that no one uses and just fix the basic functionality!

0
Comment actions Permalink

You must have faced the issue because node_modules are only partially excluded - direct dependencies listed in package.json are added to JavaScript libraries and thus included.

Use In Project scope for searching. JavaScript libraries are only included when using Directory scope with corresponding folder selected, or when using custom scope with explicit filters

0
Comment actions Permalink

Hi Elena, 

So for the node_modules that are part of the JavaScript libraries can these be excluded in the custom scope?  In the more recent version of IntelliJ is there a different way to have node_modules excluded from searching (such as find usage) but still be available for completion.  FYI, I can't make the directory as excluded because this makes it so the classes aren't available for completion.  Thanks!

0
Comment actions Permalink

Excluding libraries from custom scope is a bit tricky... To make it work, you need to prefix your scope pattern with file[your_project_name]:*/&& to overwrite the default scope - see https://youtrack.jetbrains.com/issue/IDEA-145142#comment=27-1156171 for explanation

Related feature request: : https://youtrack.jetbrains.com/issue/IDEA-103560

0
Comment actions Permalink

Thanks Elena, it worked!  Let me now if this is a enhancement request to handle this is a more straightforward way.

0
Comment actions Permalink

FYI, I see you referred to the feature request.  FYI, when the node_modules is setup as a library root then just searching for project files excludes these, which is exactly what I needed.  

0

Please sign in to leave a comment.