We all know and use npm start, npm audit, npm init and many more npm commands on a daily basis, but there are quite a few of them that are underutilized ! This article is here to show you some awesome things you can do with the npm CLI.
npm pack
Create a tarball from a package
If you're developing an npm package and want to test if it installs without publishing, running npm pack will package your module into a tgz file that can be installed using npm install.
π Docs
npm outdated
Checks for outdates packages
Pretty self-explanatory, it checks the registry if any of the currently installed packages are outdated.
π Docs
npm prune
Remove extraneous packages
Removes packages that are not listed on the parent package's dependencies list.
π Docs
npm star <pkg>
Mark your favorite packages
Allows you to show some love for a given package.
npm stars lists your currently starred packages.
π Docs
npm view <name> <field>
View registry info
You may also add any field that can be found in a package.json such as dependencies to view the related information.
π Docs
npm docs <pkg>
Docs for a package in a web browser
How many times did you end up looking for a package's documentation manually? Running npm docs <pkg> will automatically open the relevant page for you (only if it is listed in the package's package.json file).
π Docs
npm dedupe
Reduce duplication
Dedupe searches the local package tree and tries to simplify its structure by moving dependencies further up the tree. This way, they can be shared more effectively by multiple dependent packages.
π Docs
npm completion
Tab Completion for npm
Running npm completion will display a bash script that will take care of auto-completion of any future npm command. All you have to do is follow the instructions given by the command.
In my case, npm completion >> ~/.bashrc was enough for me to take advantage of that feature !
π Docs
And that's enough for one day !
Some of these commands are really, really useful in my opinion so I hope you've enjoyed this article.
If you did, following me on Twitter @christo_kade is probably the best way of showing your support. I post a lot about some cool open-source things I find, JS & CSS tricks and much more.
Thank you for reading !





Top comments (6)
One trivia for
npmis thatnpm isntallis a legit working command, as an alias tonpm installπFor details: github.com/npm/npm/issues/2933#iss...Hahaha, today I learned π
This made my day, thanks for sharing π
Great list Christopher. I haven't used some of these commands yet so this is really good to know.
I wanted to add:
as well for bumping up the version of your app in your package.json for semantic versioning. I honestly didn't know that you could automatically do this until recently π²
Thank you Ana Liza !
Agreed,
npm versionis a good one to know, thanks for sharing it.Wow new to this site. Impressed as articles like this usually are the same shared commands.