In my experience, working with mono-repo projects, I almost often end up adding node_modules to my remote repo 😩.
I finally found a way of working around it, hope to share. It's gonna be brief. But should you need to grab a cup of coffee, now is a good time to do that.
Let's Get Started
A typical mono-repo project I've worked with has a following folder structure similar to this
With each folder having it own package.json file and node_modules folder
The pitfall
A common mistake is running
git add .
` in any of the folder other than the root directory, this add all content of the folder (and node_modules too 😕) to the git history.
Way out
I found out adding .gitignore to each folder (api, client in this case) with the following content
`
./node_modules
and
./api/node_modules
./client/node_modules
in the root folder will make sure node_modules is not added to the remote repository even if you run
git add .
`
in any of the folders having node_modules
Top comments (0)