I have a project containing multiple other projects :
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/*
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With