Excluding node_modules when using tree command on Mac

Updated: February 23, 2022 By: A Goodman Post a comment

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.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

Related Articles