How to Uninstall and Update any Dependencies through NPM ?
Last Updated :
03 Jul, 2024
Node Package Manager (NPM) is an essential tool for managing dependencies in Node.js projects. It allows developers to install, update, and uninstall packages easily. This article will guide you through the process of uninstalling and updating dependencies using NPM.
Node Package Manager (NPM) is the primary package manager for Node.js. It is automatically installed when you install Node.js. When you use the npm client on the command line to install a package in your project, the package is installed in the node_modules folder, and information such as the package version is recorded in the package.json file.
We have different approaches to manage the dependencies according to the requirement as mentioned below:
For Project Dependencies
We can update the project dependencies using the update command:
npm update
We can update any particular project dependency using the following command:
npm update <packagename>
We can uninstall a project dependency using the following command:
npm uninstall <package_name>
For Global Dependencies
We can update the global dependencies using the update command with the -g flag.
npm update -g
We can update any particular global dependency using the following command:
npm update -g <package_name>
We can uninstall a global dependency using the following command:
npm uninstall -g <package_name>
Steps to Setup Project
Step 1: Make a folder structure for the project.
mkdir myapp
Step 2:Â Navigate to the project directory
cd myapp
Step 3: Initialize the NodeJs project inside the myapp folder.
npm init -y
Project Structure:
Note: Now to begin with the example we will install an old version of two packages named express and chalk using the following command on the command line.
npm install [email protected] [email protected]
The updated dependencies in package.json file will look like:
"dependencies": {
"chalk": "^2.3.1",
"express": "^4.15.4",
}
To see the outdated packages for your project you can run the following command.
npm outdated
When using the outdated command we get the following output. In the output, the first column is the name of the package and the second column shows the version installed for our project. The third column represents the wanted version that is the version to which we can safely upgrade without any breaking changes. The fourth column represents the latest version of that package.
Now, when we use the npm update command then both the packages are updated to the latest safe versions and we get the following output. As the wanted and the latest version of the express were the same, it got updated to the latest version. The only outdated dependency we are left with is chalk.Â
For Uninstalling

The updated dependencies in package.json file will look like:
"dependencies": {
"express": "^4.19.2",
}
Similar Reads
Non-linear Components In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co
11 min read
JavaScript Tutorial JavaScript is a programming language used to create dynamic content for websites. It is a lightweight, cross-platform, and single-threaded programming language. It's an interpreted language that executes code line by line, providing more flexibility.JavaScript on Client Side: On the client side, Jav
11 min read
Web Development Web development is the process of creating, building, and maintaining websites and web applications. It involves everything from web design to programming and database management. Web development is generally divided into three core areas: Frontend Development, Backend Development, and Full Stack De
5 min read
Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance
10 min read
React Interview Questions and Answers React is an efficient, flexible, and open-source JavaScript library that allows developers to create simple, fast, and scalable web applications. Jordan Walke, a software engineer who was working for Facebook, created React. Developers with a JavaScript background can easily develop web applications
15+ min read
React Tutorial React is a powerful JavaScript library for building fast, scalable front-end applications. Created by Facebook, it's known for its component-based structure, single-page applications (SPAs), and virtual DOM,enabling efficient UI updates and a seamless user experience.Note: The latest stable version
7 min read
JavaScript Interview Questions and Answers JavaScript is the most used programming language for developing websites, web servers, mobile applications, and many other platforms. In Both Front-end and Back-end Interviews, JavaScript was asked, and its difficulty depends upon the on your profile and company. Here, we compiled 70+ JS Interview q
15+ min read
Class Diagram | Unified Modeling Language (UML) A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact
12 min read
Backpropagation in Neural Network Back Propagation is also known as "Backward Propagation of Errors" is a method used to train neural network . Its goal is to reduce the difference between the modelâs predicted output and the actual output by adjusting the weights and biases in the network.It works iteratively to adjust weights and
9 min read
3-Phase Inverter An inverter is a fundamental electrical device designed primarily for the conversion of direct current into alternating current . This versatile device , also known as a variable frequency drive , plays a vital role in a wide range of applications , including variable frequency drives and high power
13 min read