Running npm install
(or npm ci
) can add tens of thousands of files to your computer in the node_modules
folder. These new files will trigger a search indexer, which reads every one of those files and add them to the search index. That adds up to a lot of lost system performance.
Users can also expect security software to add to the performance cost, as every file access may trigger or even wait for one or more security packages to perform threat assessment.
You probably don't want to search node_modules
folders from in your OS, nor do you want their contents to show up in searches. You might wander into node_modules
intentionally on occasion, but you're much more likely to do this in your editor/IDE.
Exclude From Indexing
So save yourself the trouble and disable indexing on these folders!
You can isolate each node_modules
folder separately, or, if you are like me, exclude the folder containing all of your repositories from indexing. My IDE provides fast indexed searching, and I rarely need to search for code at the OS level, so one entry saves me a lot of time.
macOS
- Open
System Settings
. - Choose
Siri & Spotlight
. - At the bottom, click
Spotlight Privacy…
- Click the Plus (
+
) button at the bottom of the list and select a folder you want to exclude. - Repeat for all the folders you want.
Windows
- Open
Settings
. - Choose
Privacy & security
. - Click
Searching Windows
. - Under
Exclude folders from enhanced search
, clickAdd an excluded folder
. - Repeat for all the folders you want.
Enjoy!
That's it! Experience extra performance, less heat and improved battery life, and enjoy getting some of that computer performance back.
Side Quests
More folders
You might consider excluding the central npm package cache, or other folders that see a lot of updates or churn. The fewer cycles your system wastes on indexing files you will never search for, the more it has available for you!
Package Managers
You might save even more time, energy, and disk space using a package manager like pNPM
, where the packages are added using file-system links rather than many duplicate fresh package installs. Then exclude the pNPM cache from indexing, too!
Header image created with DALL-E 3 through Microsoft Copilot Designer
Top comments (1)
great suggestion - I knew about that but it was totally hiding from my cognitive process lol