NPM is known as Node Package Manager. It is a popular open source Javascript Library. Npm is written entirely in JavaScript and was developed by Isaac Z. It's initial release was on January 12, 2010. It's recent stable release was released on 23 July 2019 and the version number is 6.10.2 . It is based on Artistic License 2.0. The entire library is maintained and managed by npm.inc .
Npm is a Command line tool where you can install, uninstall, update and delete new javascript packages. It is also a online platform tool where people can publish their Javascript packages to help other people. To publish your javascript libraries visit the the npm platform. Npm is serving the fortune 500 companies. It is used to build modern and powerful applications with the help of these open source and powerful javascript libraries. It contains about 800,000 code packages. Many organizations use npm to develop open source as well as private projects.
Install Open Source Packages: You can install the packages to your projects based on your needs. Packages are a piece of code written by someone that will help other developers to easily establish the particular functionality easily by importing it.
Publishing your packages: You can also help other developers with your packages by publishing them at npm
Open Source
It is one of the most important advantage of npm. It is completely free for everyone that's why it is more popular and powerful.
Dependency management
Every library has its own dependencies and without these dependencies the library or package dont work. It's a very hectic work for the Developer to install all the dependencies but npm automatically installs it for us when we install the package or library.
Version Control
The packages installed via npm are updated frequently. It takes care thar we always use the latest version of the package. Npm automatically updates the package to the current stable version of that package.
User Friendly
It is easy to use for any users we have a group of commands that are readable and easily understood for beginners.
Excellent Docs
The documentation of npm is in a well structured format easy to refer to all commands and their description. Do refer the npm docs.
The prerequisite for installing npm is Node.js as npm comes along with Node.js. To install Node.js visit its website.
Your project must contain a package.json file which keeps tract of all the packages you are using in your project.You can create one by
cd myproject
npm init
The install command is used to install a particular package in your system i.e the install command followed by the package name.
C:\>npm install <package>
>npm install <package>
The --save flag ensures that your library is added to package.json file.
npm install <package> --save
The Uninstall command removes the package from the project.
$ npm uninstall <package>
The update command helps to update the version of the package and also the dependencies of that particular package.
$ npm update <package>
The search command is used to search for a particular package by thier name in npm.
$ npm search <package>
To publish your package or directory into npm you have to have a package.json file so to get it navigate to the directory and
$cd mypackage
$npm init
To check whether you have logged in or not.
$npm whoami
if not login then Type your Username and password
$npm login
Username: <your username>
Password: <your password>
Publish your package using the publish command after logging in
$ npm publish