Skip to content

Instantly share code, notes, and snippets.

@nk-gears
Forked from lmcneel/remove-node-modules.md
Last active November 14, 2020 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nk-gears/c8e50847ae3614ac58a9341e25100aa5 to your computer and use it in GitHub Desktop.
Save nk-gears/c8e50847ae3614ac58a9341e25100aa5 to your computer and use it in GitHub Desktop.
How to remove node_modules after they have been added to a repo

How to remove node_modules

  1. Create a .gitignore file in the git repository if it does not contain one

touch .gitignore

  1. Open up the .gitignore and add the following line to the file

**/node_modules

  1. Remove the node_modules folder from the git repository

git rm -r --cached node_modules

  1. Commit the git repository without the node modules folder

git commit -m "Removed node_module folder"

  1. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment