5 useful npm commands you should use

Tram Ho

Today arranged to give the source code to add 1 feature. I cloned and then npm audit , it shows some pretty strange libraries that I’ve never used. I immediately typed the date npm docs <Tên package> it immediately opened the docs of that package => it’s really cool. The Japanese boss sitting next to him saw the rumbling cmd and his face turned blue.

In this article, I will share some simple npm commands that I often use.

1. Open the homepage containing the package’s documentation

This saves me so much time I wish I knew this trick sooner. It sounds virtual right? But really, just try it and you’ll be hooked. Since I know it, I diligently read the document, so every time I read the code I see a strange library, I type npm docs ... the main page appears immediately.

In the past, when I wanted to query lodash ‘s usage documentation, I always searched for its address via google => lazy.

In fact, npm can help you open docs quickly. Usage is very simple, You just need to run npm docs xxx to quickly open xxx documents of the package

2. Open the GitHub repo of the package

As a programmer, I guess you like github as much as I do, this is a treasure trove for programmers.

Sometimes I want to know the source code of a package, I can only search for the package name on github ?

The answer is no, npm can help you quickly open the GitHub repo of that package

3. Check Outdated Package Dependencies

Run npm outdated command in your project and it will check all packages for current version, required version and latest version.


4. View all versions of a package

Do you know how to see all versions of a package?

Yes, we can do this through the npm home page.

For example this is like the link below…



Is there any other way? That’s great, all you need is just this one command.


5. Find risky packages in your project

The audit command sends a description of the dependencies configured in your project and reports on detected vulnerabilities. If any vulnerabilities are found, the impact will be calculated and the appropriate remedial action will be taken. If the fix argument is provided, then the remedy will be applied to package tree .



As always, I hope you enjoyed this article and learned something new.

Thank you and see you in the next posts!

If you find this blog interesting, please give me a like and subscribe to support me. Thank you.


Share the news now

Source : Viblo