It's standard practice to add the node_modules directory to your .gitignore file. The list of dependencies is in the package.json file and all will be installed when you clone it and run npm install .
If you forgot to add the node_modules folder to the .gitignore file when pushing your project to github and now you want to remove it.
First add the node_modules to your .gitignore file then run the commands below
git rm -r --cached node_modules
git commit -m " removed the node_modules dir and added to .gitignore"