Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git - Ignore node_modules folder everywhere

I have a project containing multiple other projects :

  • Main project
    • Mini project 1
    • Mini project 2

All containing node_modules folder. I want git to ignore the folder no matter where it is starting from the root folder. Something like this to add in .gitignore :

*node_modules/* 
like image 909
Mehdiway Avatar asked Apr 23 '15 10:04

Mehdiway


People also ask

Should you Git ignore node_modules?

Not committing node_modules implies you need to list all your modules in the package. json (and package-lock. json ) as a mandatory step. This is great because you might not have the diligence to do so, and some of the npm operations might break if you don't.

Does Git automatically ignore node_modules?

It's commonly used to exclude auto-generated files in your project. And with that, your node_modules/ folder will be ignored by Git. This works even when you have multiple node_modules/ folders located inside another subfolders.

How do I ignore a folder in Git?

If you want to maintain a folder and not the files inside it, just put a ". gitignore" file in the folder with "*" as the content. This file will make Git ignore all content from the repository.


1 Answers

Add node_modules/ or node_modules to the .gitignore file to ignore all directories called node_modules in the current folder and any subfolders like the below image.

example

like image 161
Alik Avatar answered Oct 08 '22 02:10

Alik