In this lesson, we will learn about npm
, the Node Package Manager and how and why it is used in Node.js development.
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:
npm
website – used for finding packages, creating profiles, and managing other aspects of ournpm
usage.- CLI or a Command Line Interface (CLI) – used to interact with
npm
and is run from a Terminal/Command Prompt. npm
registry – used as the public database of JavaScript software/dependencies.
There are a lot of benefits of using npm
. Some major ones are as listed below:
- It is easier to adapt code packages for your applications, or simply use them as-is.
- Helpful in installing standalone tools that you can use right away.
- Can be used to distribute code to any
npm
user. - Manage multiple code versions and code dependencies.
- When the underlying code is updated, it is simple to update applications.
- Discover various approaches to solving the same problem.
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.