Node Package Manager (npm)


This entry is part 4 of 2 in the series Node

npm makes it easy for JavaScript developers to share the code that they’ve created to solve particular problems, and for other developers to reuse that code in their own applications. Once you’re depending on this code from other developers, npm makes it easy to check to see if they’ve made any updates to it and to download those updates when they’re made.

These bits of reusable code are called packages or modules. A package is just a directory with one or more files in it, along with a file called “package.json” that contains metadata about the package. A typical application, such as a website, will depend on dozens or hundreds of packages. These packages are often small; the general idea is that you create a small building block which solves one problem well. This makes it possible for you to compose larger custom solutions out of these small building blocks.

Why use npm? There’s lots of benefits to this; it makes it possible for your team to draw on expertise outside of your organization by bringing in packages from people who have focused on particular problem areas. Even if you don’t reuse code from people outside of your organization, using this kind of module-based approach can help your team work together better and make it possible to reuse code across projects.

You can find packages to help you build your application by browsing the npm website. When you’re browsing the website, you’ll find lots of Node modules. npm started as the Node package manager, so you’ll find lots of modules which can be used on the server side. There are also lots of packages which add commands for you to use in the command line. You’ll also find packages which can be used on the front end.

nmp can refer to three different things.

  • the website
  • the registry (a big database of information about packages people are sharing)
  • the npm client (the command line interface)

The command line interface (client) is installed on a local computer. It is used to publish the code up to the registry. Other developers can use the client to install this new package from the registry.

Series Navigation<< Node.js Introduction