Update: there is an updated version of this at /2016/05/11/reinstall-daggumnpm/
No matter what version of npm you use, you likely have had
to destroy your
node_modules folder and do a clean
npm install to debug some
issue. This likely isn’t exclusive to npm either, but any package manager.
Regardless, here’s a quick friendly bash script to reinstall your
fresh, let you know when it’s done, and automatically run the previous command.
alias daggumnpm='rm -rf node_modules && npm i && say "Rerunning `!!` && !!'
If you’ve used node at all the first two commands should be straightforward.
rm: remove things.
-rfmeans recursively destroy a directory.
npm i: alias for
say "Rerunning \!!`": use your computers robot voice to audibly say Running whatever that double exclamation point is.
!!: This is the fun one. Execute the previous command. https://www.digitalocean.com/community/tutorials/how-to-use-bash-history-commands-and-expansions-on-a-linux-vps#executing-commands-from-your-bash-history For example, you ran
npm startand it failed with some dependency issue.
daggumnpmwill do a clean npm install and rerun
npm startfor you.
These words brought to you by Dustan Kasten. A friendly, bearded, husband, father, and user interface engineer living in Charlotte, NC. Considers himself quite partial to React.js these days. Find @iamdustan on Twitter