DEV Community

Impress your colleagues with these NPM tricks

Piero Borrelli on May 13, 2019

Just like anyone else, developers enjoy knowing some little tricks to show to their colleagues or friends. Today, I have decided to write about s...
Collapse
 
nickytonline profile image
Nick Taylor

Also, npx. 😎

With the latest version of node, you can just do npx mocha instead of having to add ./node_modules/.bin/ to your PATH.

Collapse
 
renrizzolo profile image
Ren

Nice - repo will come in handy I'm sure.
npm outdated is another good one I use a lot! Gives you a table of installed and latest versions of your packages.

Collapse
 
jcserracampos profile image
Júlio Campos

And you can use nom outdated -g to see global packages.

PS.: It's broken in some versions of NPM, so update your NPM.

Collapse
 
darksmile92 profile image
Robin Kretzschmar

Thanks for the list!
npm repo and npm home was new to me and something I will use really often because if we are honest: no one bookmarks the docs of a package, we hit google and hope it is under the top results 😁

Collapse
 
borrellidev profile image
Piero Borrelli

glad to hear it will speed up your workflow!

Collapse
 
euginio profile image
Eugenio Arosteguy

The -S param is still needed for confuse and impress your colleagues

Collapse
 
qrzy profile image
Qrzy

Many thanks for repo, TIL :)

I'd add ci and outdated. ;)

Collapse
 
amejiarosario profile image
Adrian Mejia

Oh, I didn't know about npm version patch and npm t. Very cool!
I wonder if you can run other scripts when bumping the version of a package (like publishing it to npm automatically and generating the changelog)

Collapse
 
owl profile image
Oscar

I use np for publishing.

github.com/sindresorhus/np

Collapse
 
amejiarosario profile image
Adrian Mejia

Oh, this is a live saver! Thanks for sharing it :)

Collapse
 
sherlockliu profile image
Sherlock

Thanks for your blog to teach us so many tricky things, May I ask how you make those pictures?

Collapse
 
borrellidev profile image
Piero Borrelli

Thank you so much for your words, I use an online tool called carbon.now.sh/. You can use it to make cool code images and set the color, background etc.

Collapse
 
sherlockliu profile image
Sherlock

Thanks man.

Collapse
 
rad_hombre profile image
Matthew Orndoff • Edited

npx npkill is a great one to free up hard drive space. Searches your system for node_modules directories, displays their sizes, and allows you to quickly delete them.

Collapse
 
vlads profile image
0x766c6164

I found npm set progress=false to help me when using npm.

Collapse
 
pairedprototype profile image
PairedPrototype

npm t will be greatly welcomed to my npm vocabulary. Thanks!

Collapse
 
dimpiax profile image
Dmytro Pylypenko

It’s literally ‘npm test’, in the same way as ‘npm start’.

Collapse
 
rafi993 profile image
Rafi • Edited

Then there is

npm visnup

which does this
https://dev-to-uploads.s3.amazonaws.com/i/gf6cl1f6wubl4rrj6cdh.png

npm xmas

https://dev-to-uploads.s3.amazonaws.com/i/7pv6a48a8ir2e0uuhptr.png

and

npm substack

(try running it multiple times)

Collapse
 
amberwilkie profile image
Amber Wilkie

npm repo <package> is clutch.

Collapse
 
emasuriano profile image
Ema Suriano

Great article! 👏 Didn't know about npm run, it's quite useful. I was doing cat package.json | grep "\"scripts\":" -A 8 😅

Collapse
 
ambroseus profile image
Eugene Samonenko

alias t='npm t'
😎

Collapse
 
peacefulseeker profile image
Alexey Vorobyov • Edited


npm i package -E

will save an exact version of the package

Collapse
 
motss profile image
Rong Sen Ng

I'm impressed.

Collapse
 
borrellidev profile image
Piero Borrelli

thank you so much for the appreciation! Hope this helped you to discover something new you will be able to apply!

Collapse
 
leonblade profile image
James Stine

Great resource, thanks!

Collapse
 
kdev291 profile image
@kdev29 • Edited

Great post, thanks

Collapse
 
tamouse profile image
Tamara Temple

useful!

Collapse
 
pinguinosod profile image
David Cautin

I ran npm ls --depth 0 and I got a lot of errors because missing dependencies 😂 🤣

Collapse
 
vikkihub profile image
Vikas Yadav

very helpfull.
Thanks Piero for sharing these wonderful commands