NPM - Node Package Manager
NPM - Node Package Manager
Previous Next
Node Package Manager (NPM) is a command line tool that installs, updates or uninstalls Node.js packages in your application. It is also an online repository
for open-source Node.js packages. The node community around the world creates useful modules and publishes them as packages in this repository.
C:\> npm -v
2.11.3
If you have an older version of NPM then you can update it to the latest version using the following command.
To access NPM help, write npm help in the command prompt or terminal window.
NPM performs the operation in two modes: global and local. In the global mode, NPM performs operations which affect all the Node.js applications on the
computer whereas in the local mode, NPM performs operations for the particular local directory which affects an application in that directory only.
Use the following command to install any third party module in your local Node.js project folder.
For example, the following command will install ExpressJS into MyNodeProj folder.
All the modules installed using NPM are installed under node_modules folder. The above command will create ExpressJS folder under node_modules folder
in the root folder of your project and install Express.js there.
Use --save at the end of the install command to add dependency entry into package.json of your application.
For example, the following command will install ExpressJS in your application and also adds dependency entry into the package.json.
package.json Copy
{
"name": "NodejsConsoleApp",
"version": "0.0.0",
"description": "NodejsConsoleApp",
"main": "app.js",
"author": {
"name": "Dev",
"email": ""
},
"dependencies": {
"express": "^4.13.3"
}
}
NPM can also install packages globally so that all the node.js application on that computer can import and use the installed packages. NPM installs global
packages into /<User>/local/lib/node_modules folder.
Apply -g in the install command to install package globally. For example, the following command will install ExpressJS globally.
Update Package
To update the package installed locally in your Node.js project, navigate the command prompt or terminal window path to the project folder and write the
following update command.
https://www.tutorialsteacher.com/nodejs/what-is-node-package-manager 1/2
4/23/23, 1:11 AM NPM - Node Package Manager
The following command will update the existing ExpressJS module to the latest version.
Uninstall Packages
Use the following command to remove a local package from your project.
Previous Next
TutorialsTeacher.com Tutorials
TutorialsTeacher.com is optimized for learning web technologies step by step. ASP.NET Core JavaScript
Contact Us C# Angular 2
Object-Oriented C# D3.js
LINQ Sass
Go Lang AngularJS 1
SQL
SQL Server
MongoDB
PostgreSQL
Entity Framework
E-mail list
Subscribe to TutorialsTeacher email list and get latest updates, tips & tricks on C#, .Net, JavaScript, jQuery, AngularJS, Node.js to your inbox.
Email address GO
HOME TERMS OF USE PRIVACY POLICY 2023 TutorialsTeacher.com. All Rights Reserved.
https://www.tutorialsteacher.com/nodejs/what-is-node-package-manager 2/2