Embarrassingly, I didn't know how to do this before and kept deleting the node_modules file then running
npm -i which does work but it's unnecessary and kills my workflow. In the spirit of efficiency. This is how to avoid that workflow altogether!
Ever heard or seen
gitignore before? Well, I had but didn't think anything of it.
gitignore file specifies what files you don't want GitHub to accept on pushes.
Super easy setup:
In the root of your project run:
touch .gitignore and in it you just need to specific patterns.
Something like this:
Save that file and you are all set. From now on when you push,
node_modules directory will be ignored!
In Visual Studio Code I use an extension called Github that allows you to push/pull from a repository with 2 clicks. You can see in this gif below that when I add this line of code, the GitHub extension automagically updates to ignore those 3K+ files in my
node_modules directories within various projects in my portfolio.