Two minutes on NPM

Hiruni Malaviarachchi
Path to full stack development
2 min readApr 16, 2020

What is NPM?

NPM, which stands for Node Package Manager is the world’s largest software library and it works as an installer too. It is identified as the default package manager for the javascript run time environment Node.js.

NPM consists of three distinct components:

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

Use npm to-

  • Adapt packages of code for your apps, or incorporate packages as they are.
  • Download standalone tools you can use right away.
  • Run packages without downloading using npx.
  • Share code with any npm user, anywhere.
  • Restrict code to specific developers.
  • Create Orgs (organizations) to coordinate package maintenance, coding, and developers.
  • Form virtual teams by using Orgs.
  • Manage multiple versions of code and code dependencies.
  • Update applications easily when underlying code is updated.
  • Discover multiple ways to solve the same puzzle.
  • Find other developers who are working on similar problems and projects.

Global installations will be available throughout the system while local installations will only be available for that particular application. By default, all the dependencies will get installed to ‘node_modules’ directory. ‘package.json’ contains all information related to the NodeJS application. The file be placed in the root directory of the application. ‘package.json’ will contain name, version, author, repository, required node version, scripts and dependencies etc.

Install NPM

npm is distributed with Node.js- which means that when you download Node.js, you automatically get npm installed on your computer.

Here I have included the link to download node.js LTS that is recommended for most users.

To check if you have Node.js installed, run this command in your terminal:

node -v

To confirm that you have npm installed you can run this command in your terminal:

npm -v

A note on versions

npm versions

npm is a separate project from Node.js, and tends to update more frequently. As a result, even if you’ve just downloaded Node.js (and therefore npm), you’ll probably need to update your npm. Luckily, npm knows how to update itself! To update your npm, type this into your terminal:

npm install npm@latest -g

A simple note to keep on mind — try npx instead of npm if you do not want to install packages.

--

--