The 8 NPM commands you never knew existed
NicolasBrondinBernard
The 2nd one will surprise you (maybe not)!

Article published on 30/11/2020, last updated on 10/08/2026
If, like most people, you only use NPM through its "install" or "run" commands, you're going to discover that this package manager has nothing to be envious of compared to others.
Indeed, even though it's customary to use it alongside a search engine and a browser to find the packages you want, NPM lets you do everything without ever going through another tool, if you so wish.
Running a security audit
This is THE most important command on this list because building software on dependencies and sub-dependencies can be just as much an advantage as a drawback.
Obviously, the hundreds of thousands of packages available on NPM let you avoid reinventing the wheel, but this sometimes has the consequence of opening a security flaw in your software if one of its dependencies has been compromised.
$> npm audit
This command lets you run a security audit on all the dependencies declared in the project, along with their severity level and, most importantly, the ability to resolve them by updating each affected package.
Checking the connection to the registry
Having a download problem with one or more packages? Need to know whether the firewall or proxy security rules allow the server to install all of the application's dependencies?
$> npm ping
With the "ping" command, you can get an immediate answer as to whether npm is able to connect to its package registry or not.
Searching for a package
Are you used to searching for your packages on Linux directly in your terminal with "apt search"? Then you won't feel out of place, because you can do the same thing with npm!
$> npm search <query1> <query2> ...
Listing installed dependencies
By listing installed dependencies, you can get a graph-based view of all the packages present in a project, along with an indication of whether a package serves as a sub-dependency for several other packages.
$> npm list --all
You can also do the same thing for packages installed globally on the machine with the following command:
$> npm list --global
Displaying a package's details
If you want to know the version number of the latest release of a package, or the list of its dependencies, the number of versions created since the beginning, as well as plenty of other information, all you have to do is type the following command:
$> npm view <package>
Displaying a dependency's docs
If you want to open a package's official documentation and you feel like saving the 5 to 10g of CO2 generated by a Google search, you can do so with the command:
$> npm docs <package>
or its variant:
$> npm home <package>
Which will open the homepage of the package's presentation site, which sometimes differs from the site where the documentation is located.
Funding an open-source project
Funding within the open-source community is a real problem, and NPM has decided to tackle this problem by allowing project creators to announce their need for money to support the project, along with a command so that every user can easily find out about it.
That command is:
$> npm fund <package>
As a bonus
If you don't know exactly what the package-lock.json file is for in a project, here's an article on its importance, with another NPM command thrown in as a bonus: https://code-garage.fr/blog/what-is-the-package-lock-json-file-for-and-should-you-commit-it/
No spam. Only free content, news, and ever more resources to level up your skills!
Join +1500 developers
No comments yet