Problem Statement
The node_modules directory contains all your project’s dependencies. Since these files can be large and are recreated using package.json, it’s best practice to exclude them from version control.
Solution
To ignore the node_modules folder from being tracked by Git
Open (or create) a .gitignore file in the root of your project.
Add the following line
Save the file.
If node_modules was already being tracked, remove it using
Then commit the changes
Also Read:
Push to your repository
Conclusion
Using a .gitignore file helps maintain a clean repository and reduces unnecessary data. Excluding node_modules also ensures faster cloning and a smaller repo size.