Adding autocomplete to npm install

Jamis Charles
May 27, 2016 · 1 min read

Originally published at

Every time I have to type this without autocomplete I get really annoyed:

I spent a few hours last night and figured it out.

Adding autocomplete

Solutions below are for bash / zsh only (not Windows, sorry).

If you don’t use npm autocompletion yet, add this snippet to your ~/.bashrc:

If you use zsh, add this to ~/.zshrc.

If you already use npm autocompletion, replace your version with this one:

How it works

We run `ls ~/.npm` and pass all the results as options to bash/zsh autocompletion for the `npm install` command. ~/.npm is the location of the npm cache. This should contain any packages you’ve installed at some point (Not all of npm.).

Questions, comments, feedback? I’m a bash newb, so any improvements are welcome.

Thanks to Kent C. Dodds

Jamis Charles

Written by

UI Engineer at PayPal. @jamischarles — Thoughts are my own. Blog at I run a sweet job board at

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade