Pushing Your Code to Git (without the node_modules folder)

Β·

2 min read

Pushing Your Code to Git (without the node_modules folder)

Photo by Yancy Min on Unsplash

I think we can all agree that most developers have tried to utilize the Version Control System known as Git to track our code. More so, it is likely that there is a high percentage of us that made the mistake (might not be, though) of uploading the node_modules folder in our project along to the git repository.

Heck,I have made this mistake a couple of times and was frustrated every time. You already know why, but for those that don't, the size of a node_modules folder can be very heavy due to the dependencies (or npm packages) that are being used in a particular project.

nodemodulesmeme.webp

Very funny but true.πŸ˜† Just don't underestimate the size of your node_modules folder.


Here is the simple way one can avoid pushing the folder:

  • Create a .gitignore file inside your project folder. This file is a text file that tells Git which files or folders to ignore in a project.

  • Inside this file, you must specify the file/folder you want to ignore. In this case, the node_modules folder. We can do this by writing in the file:

/node_modules
  • Save the file.

This is how it should look like in your favorite text editor. hashnode.png


Now, you can go ahead!πŸš€ Push that code to your Git repository without having the dreadful folder tag along. Yes! We can avoid the reality of this meme.😁

memedev.jfif


I hope this read was fun as well as informative.😩 If so, I'mma catch y'all on the next one.

Danke SchΓΆn πŸ™

Β