Kinda Code
Home/Node/Excluding node_modules when using tree command on Mac

Excluding node_modules when using tree command on Mac

Last updated: February 23, 2022

The node_modules folder is often super big and contains countless files and subdirectories. Therefore, when using the tree command to display your project file structure, you should ignore node_modules. To do so, try this:

tree -I 'node_modules'

The result:

If you want the command to exclude more than one directory, you can use:

tree -I 'folder-1|folder-22|folder-3|folder-4'

Simple as that. Hope this short article can help you a little bit in some way.

Further reading:

You can also check out our Node.js category page for the latest tutorials and examples.