Visual Studio - Find in files > not any node_modules folders
Asked Answered
K

2

8

So in Visual Studios you can "Find in files" a string - I find this very useful to locate a file in which some markup or JS may be found, I use VS for my main code editor for Web development.

The problem is, most of my projects use node.js and node based build tools grunt/gulp etc. so I have a node_modules folder somewhere in my project that makes the FIND take for ever as there are thousands of files!!

How can I search in files and folders for a string BUT not in a node_modules directory.

In SublimeText2 you can remove a folder from the project without deleting it, this will stop a search looking in there...

A RegExp will be for the string not the filePath :(

Kim answered 17/6, 2014 at 13:27 Comment(2)
Can you exclude the node_modules folder from the project? Alternatively can you hide the node_modules folder (do they have a common root), by setting the Hidden attribute on the folder?Centipede
That's a good idea, it stops Visual Studio searching inside & doesn't stop Grunt from running. - would need to test this idea running a node server and gulp. I don't mind making the folder hidden on each project a fairly small change to stop irritation and increase #velocityKim
C
13

Ok so I've tried this and it seems to work.

You can hide the node_modules folder (if they have a common root), by setting the Hidden attribute on the folder. As you say it fulfils your needs as per the question.

Centipede answered 9/10, 2014 at 10:54 Comment(1)
Thanks @alergy, adding the hidden attribute on the node_module directory worked for me. However, I also had to refresh the solution explorer for the search to actually exclude the hidden directory.Stclair
M
2

2020 Version

Add the following exclusion

!*\node_modules\*;!*\bin\*;!*\obj\*;!*\.*

enter image description here

Mucin answered 11/4, 2020 at 14:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.