Skip to content

Instantly share code, notes, and snippets.

@sam-artuso
Last active February 11, 2017 20: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 sam-artuso/2abe70f280cd865f2ee9f70b4d956208 to your computer and use it in GitHub Desktop.
Save sam-artuso/2abe70f280cd865f2ee9f70b4d956208 to your computer and use it in GitHub Desktop.
How I stopped myself typing npm instead of yarn

Yarn is the new fancy NPM client by Facebook. Compared to the good ol' npm command line client, Yarn is faster and provides by default what you can achieve with npm shrinkwrap. It's even got fancier output. Emojis apart, its output is more succinct than npm's, which spits out a lot of things I don't really want to know about.

After switching to Yarn I found out how much I rely on muscular memory when typing on my keyboard. I found myself typing by mistake npm install when I should've typed yarn add When this happens, the yarn.lock file stops reflecting what is installed in the node_modules/ directory.

My solution to this problem was to alias npm like below. This alias will check if yarn.lock exists, stop me and even tell me off.

npm='test -e yarn.lock && >&2 echo "yarn.lock found in current directory. Use yarn instead." || npm'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment