Skip to content

Latest commit

 

History

History
40 lines (25 loc) · 1.99 KB

File metadata and controls

40 lines (25 loc) · 1.99 KB

Text

In this lesson, we will learn about npm, the Node Package Manager and how and why it is used in Node.js development.

What is npm?

npm (Node Package Manager) is a command-line tool for installing, creating and sharing packages of Node.js JavaScript code. There are many open-source packages available on npm, like packages for working with dates or fetching data from a web server.

Many businesses also use npm to manage private development within their organizations. npm is made up of three distinct elements:

  1. npm website – used for finding packages, creating profiles, and managing other aspects of our npm usage.
  2. CLI or a Command Line Interface (CLI) – used to interact with npm and is run from a Terminal/Command Prompt.
  3. npm registry – used as the public database of JavaScript software/dependencies.

Why use npm?

There are a lot of benefits of using npm. Some major ones are as listed below:

  1. It is easier to adapt code packages for your applications, or simply use them as-is.
  2. Helpful in installing standalone tools that you can use right away.
  3. Can be used to distribute code to any npm user.
  4. Manage multiple code versions and code dependencies.
  5. When the underlying code is updated, it is simple to update applications.
  6. Discover various approaches to solving the same problem.

Working with npm

npm is bundled along with Node.js while you install it. If you have followed the previous lesson to get Node.js set up on your system, you will already have npm configured for you to work with.

To check if you already have Node.js and npm installed, run the following commands on your Terminal:

node --version

npm --version

The above commands will provide you with details about the Node.js and npm versions installed on your system.

In the upcoming lessons, we will learn more about the ways in which we can use npm to configure and work with our Node.js application.