How to remove node_modules folder from github/bitbucket

If your mistakenly push the node_module folder on github/bitbucket respo.  Don’t worry you can easily remove the folder. Follow the below steps:


  1. Create a .gitignore file in the git repository if it does not contain one
    touch .gitignore.
  2. Open up the .gitignore and add the following line to the file node_modules.
  3. Remove the node_modules folder from the git repository git rm -r –cached node_modules.
  4. Commit the git repository without the node modules folder git commit -m “Removed node_module folder”.
  5. Push the repository to github
git push origin master

After all of that, you should also add the gitignore and commit it to the repository

git add .gitignore

git commit -m "Updated the .gitignore file

git push origin master


Was this post helpful?
Let us know if you liked the post. That’s the only way we can improve.
Harinder Singh

Harinder Singh

My name is Harinder Singh and I specialize in Software industry. I consider myself as a life learner. I love learning new concepts, embracing new ideas and reading and searching for innovation.