What is NPM? Why we need it?

Freddychris A
3 min readMay 31, 2022

What is NPM?
“Node Package Manager”

NPM is a main package manager for node-js is a huge repository of mostly open source software and it can be used by anyone for free.

Why do we need NPM?
For Example : What will we do if we need to build a car?
Will we go and melt the metal and casting it and using hammer to form it into the right shapes. It would take a very long time and be quite expensive.
Most people who want to build a car wont go that route instead they will start by getting all the pre-build parts they need and assembling those parts in to a complete working car.
In the same way npm makes writing code easier.Because you can reply on pre-build code that other people have written you can use their code for your own project instead of writing everything yourself. Authors will write the code for their package and publish it on the npm registry then if you want to use that package you can install it on your own computer with the “npm cli or command line interface”.

Why do we use NPM?
Because you can write your styles more quickly and efficiently than pure CSS the only problem themselves are not readable by the browser so we need to compile or convert them into CSS in a real-world development environment you would normally use some type of build tool to do the conversion for you in our case. we need to use npm to install for our workflow npm is a huge part of the Javascript ecosystem these days so its definitely a good skill set to have.

Npm is two thing :
1) Online platform
2) Command-line tool

(1) Online platform:
Online platform is a place where people including you can publish and share tools written in out favourite language JavaScript everyone can search for and use the tools publish to this online platform in the NPM platform you can find JavaScript tools which can be used in the browser the server or ever the command line.

The Tools can be used In:
*BROWSER(FRONT END)
*SERVER(BACK END)
*COMMAND LINE

(2) Command line tool
NPM is also a command-line tool that helps mortals like you and me to interact with the online platform i just mentioned here a few things you can do with the command-line tools interact with online platform.

1. INSTALL AND UNINSTALL PACKAGES
Package is a word used to talk about tools people create and upload to the NPM online platform. think of a package as a build-in block for your application you can combine several building blocks to create a cool application for an even more amazing package.

2.VERSION MANAGEMENT
Every package has a version as the package grows and improves the version of the package changes with NPM you can easily keep the packages in your project up to dates or even use a different package version.

3.DEPENDENCY MANAGEMENT
Many packages that other people create are built on top of other packages dependencies are packages that another package is built on instead of you having to search for those dependencies and install them one by one you can use one simple command to get the tool you want and NPM will do the hard work of searching for all the dependencies and installing them in your application.

Installing NPM Packages

There are two type of installing packages :
Locally
Globally

To install packages locally in the project folder that you want to use the package for this ensures that when you deploy your project it include all the necessary packages.`
Installing a package locally means that it will only be accessible from that specific project folder. If you have other projects each one will have its own set of local packages

To install a local package you’ll use the “npm cli” in the terminal

To install a package globally type in “npm install -g”
If we install the packages in globally we can use it throw our system.

References:
https://docs.npmjs.com/about-npm
https://stackoverflow.com/questions/31930370/what-is-npm-and-why-do-i-need-it

--

--