Removing node_modules files from Alfred's results

Node projects contain a lot of search-irrelevant node_modules files, which can saturate the macOS metadata index used by Alfred.

Unfortunately, the macOS metadata search API only allows Alfred to include search folders, not exclude them. As such, there is no practical way for Alfred to provide a built-in solution for this.

The only reliable option to manage what is and isn't included in the index that macOS provides is with Spotlight Privacy, so you have a few options:

  • You could manually copy the node folders to Spotlight Privacy to exclude these specifically
  • You could put the whole folder containing your node projects in Spotlight Privacy if you don't need to search them
  • You could remove the whole node projects folder from Alfred's search scope
  • Or finally, you could create a file filter workflow search that don't include those folders

Over past macOS versions, Apple have added and removed various means of ignoring files from the index, such as including a .metadata_never_index file in the node folder, which would prevent the folder from being indexed.

Currently, this solution does not appear to be working. If you discover a way to reliably exclude files, please share it with us, as it may be helpful to other community members.

Latest Blog Post:

Searching Google Drive with an Alfred workflow

CacheFly Campaign Monitor

"Alfred" is a registered trademark of Running with Crayons Ltd. ©2021 Running with Crayons Ltd. All rights reserved.

Terms & Conditions, Privacy Policy, Cookies.