Comprehensive List to NPM Commands

Do not miss this exclusive book on Binary Tree Problems. Get it now for free.

If you're working with JavaScript, you've probably heard of npm, the package manager for Node.js. npm is an essential tool for developers that allows them to easily manage and share the packages and libraries that their projects depend on. It offers a vast library of over 1.5 million packages and makes it simple to install and manage dependencies.

With npm, you can easily install, update, and uninstall packages, as well as create and publish your own packages to the npm registry. It also provides a variety of other features, such as scripts, which allow you to run custom commands and automate tasks within your project.

If you're new to npm, it can be overwhelming to learn all the different commands and their functionalities. That's why, in this article at OpenGenus, we've put together a comprehensive list of all the npm commands you'll ever need, along with explanations of what they do and how to use them.

To give you an idea of what working with npm looks like, here's an example of how to install the popular lodash library using the npm command line interface:

  npm install lodash

This command installs the latest version of lodash and its dependencies, saving it to the "node_modules" directory in your project. From there, you can import and use the library in your code.

but npm is much more than just install command. Whether you're a seasoned developer or just getting started with Node.js, mastering npm commands is an essential part of building successful projects. So, let's dive into the world of npm and discover all the powerful tools it has to offer!

List of All NPM commands

Install all packages defined in package.json

npm install

Install a particular package for the given project

npm install package_name

Install a particular package for all projects, in other words install package with global scope

npm install package_name -g

To Lists the installed versions of all dependencies in this software

npm list

Remove packages globally

npm uninstall -g package-name

Show global packages

npm list -g

List all npm configuration flags

npm config ls -l

Update the global npm version.

npm update npm -g

Locally edit a dependency

npm edit <module_name>

Test & Show the full dependency tree

npm install --dry-run

Set access level on published packages

npm access

Add a registry user account

npm adduser

Run a security audit

npm audit

Display npm bin folder

npm bin

Bugs for a package in a web browser

npm bugs

Manipulates packages cache

npm cache

Install a project with a clean slate

npm ci

Tab completion for npm

npm completion

Reduce duplication

npm dedupe

Deprecate a version of a package

npm deprecate

The registry diff command

npm diff

Docs for a package in a web browser maybe

npm docs

Modify package distribution tags

npm dist-tag

Check your environments

npm doctor

Run a command from an npm package

npm exec

Explain installed packages

npm explain

Browse an installed package

npm explore

Find duplication in the package tree

npm find-dupes

Retrieve funding information

npm fund

Search npm help documentation

npm help

Get help on npm via search

npm help-search

Manage registry hooks

npm hook

Create a package.json file

npm init

Symlink a package folder

npm link

Log out of the registry

npm logout

Manage orgs

npm org

Check for outdated packages

npm outdated

Manage package owners

npm owner

Ping npm registry

npm ping

Manage your package.json

npm pkg

Change settings on your registry profile

npm profile

Remove extraneous packages

npm prune

Publish a package

npm publish

Retrieve a filtered list of packages

npm query

Rebuild a package

npm rebuild

Open package repository page in the browser

npm repo

Restart a package

npm restart

Display npm root folder

npm root

Run arbitrary package scripts

npm run-script

Lock down dependency versions for publication

npm shrinkwrap

Mark your favorite packages

npm star

View packages marked as favorites

npm stars

Start a package

npm start

Stop a package

npm stop

Manage organization teams and team memberships

npm team

Test a package

npm test

Manage your authentication tokens

npm token

Remove a package from the registry

npm unpublish

Remove an item from your favorite packages

npm unstar

Update a package

npm update

View registry info

npm view

Display npm username

npm whoami

Run a command from an npm package

npx

Note: I have tried to cover all the available commands for npm version 8.19.2 which is the latest version as of May,2023. Any future update to npm may cause degradation of some commands or addition of more commands to the list.

Sign up for FREE 3 months of Amazon Music. YOU MUST NOT MISS.