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.
A 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:
*/node_modules/**
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.
Drew is a seasoned DevOps Engineer with a rich background that spans multiple industries and technologies. With foundational training as a Nuclear Engineer in the US Navy, Drew brings a meticulous approach to operational efficiency and reliability. His expertise lies in cloud migration strategies, CI/CD automation, and Kubernetes orchestration. Known for a keen focus on facts and correctness, Drew is proficient in a range of programming languages including Bash and JavaScript. His diverse experiences, from serving in the military to working in the corporate world, have equipped him with a comprehensive worldview and a knack for creative problem-solving. Drew advocates for streamlined, fact-based approaches in both code and business, making him a reliable authority in the tech industry.