W3cubDocs

/npm

What is npm?

npm is the package manager for JavaScript. It's also the world's largest software registry. There are over 600,000 packages of JavaScript code available to download, with approximately 3 billion downolads per week. npm makes it easy for JavaScript developers to reuse code other developers have shared. Adapt it to new applications, or incorporate it as is. When someone revises their code, you can easily update your application to incorporate the newly improved code.

Developers create a small building block of code that solves one problem well, then "package" the code into a directory that follows npm guidelines. A typical application, such as a website, will consist of dozens or hundreds of small packages. Its developer uses the packages to compose larger custom solutions.

npm makes it possible for your team to draw on the expertise of people who have focused on a particular problem areas, whether in your organization, or outside of it. Use npm to help your team work together better, sharing developer talent across projects. Use npm to manage multiple versions of code.

To find packages, browse the npm website.

While browsing, you'll find lots of Node modules, which makes sense, since npm started as the Node package manager. Node modules can be used on the server side. There are also many packages which add commands for you to use in the command line. And there are an ever-increasing amount of packages that can be used on the front end. (To understand the difference between node modules and packages, click here).

npm consists of three distinct pieces:

  • the website
  • the registry
  • the Command Line Interface (CLI)

The website is the primary way developers discover packages, set up profiles, and manage other aspects of their npm experience.

The registry is a large database of information about packages.

The CLI, run from a terminal, is how developers publish their packages on the registry or download packages they wish to install.

Example: Finding a Package

For example, suppose you wanted to use bar codes (QR codes) in your application. Rather than spend weeks figuring out how to do this, why not see if someone has posted a package that creates QR codes? Start by entering a value in the search bar:

blanksearchbar

Related options will appear:

choicessearchbar

Or, if you click, you will have a chance to filter the possibilities even more:

filtersearchbar

When you choose a package to explore, more information appears. This information is written by the package author(s) so details vary.

searchresults

Now, you can read the developer's instructions to discover how to use this package.

Next Steps

Now that you know what npm is, it's time to get started. Install npm. We look forward to seeing what you will create!

To learn more about npm as a product, new features on the way, and interesting uses of npm, sign up for our newsletter, or read newsletter archives, at npm-weekly

© npm, Inc. and Contributors
Licensed under the npm License.
npm is a trademark of npm, Inc.
https://docs.npmjs.com/getting-started/what-is-npm