Skip to main content

Command Palette

Search for a command to run...

Introduction to the Node Package Manager

Published
2 min read
Introduction to the Node Package Manager

npm is the default package manager for the JavaScript runtime environment Node.js. It was developed by Isaac Z. Schlueter, written entirely in JavaScript. npm comes with node.js. Yarn and pnpm are alternatives to npm cli.

It consists of a command line client, also called npm, and an online database of public and paid-for private packages, called the npm registry. The registry is accessed via the client, and the available packages can be browsed and searched via the npm website. The package manager and the registry are managed by npm, Inc.

To check which version of the package manager is installed on your computer use npm -v

npm manages downloads of dependencies of your project.

Installing all dependencies

If a project has a package.json file, by running npm install it will install everything the project needs, in the node_modules folder, creating it if it's not existing already.

Installing a single package

You can also install a specific package. Furthermore, since npm 5, this command adds <package-name> to the package.json file dependencies.

npm install

Updating packages

npm update

npm will check all packages for a newer version that satisfies your versioning constraints.

You can specify a single package to update as well:

npm update

Running Tasks

The package.json file supports a format for specifying command line tasks that can be run by using

npm run

More from this blog

C

Charles Kasasira - Fullstack developer

21 posts

Software engineer aiming to design and develop experiences that make people's lives simple.

Introduction to the Node Package Manager