Introduction
We all go through the hustle and bustle of having to put away summer clothes at the beginning of winter and winter wear when the mercury starts to rise. But why do we do that?
The answer is obvious - we don’t need those particular clothes.
Similarly, when we don’t need particular packages in a web application anymore, we’ll uninstall npm packages.
But do we know how to do that?

Then let’s not delay and find out how to uninstall npm packages.
Syntax to Uninstall npm Packages
To begin with, when we want to uninstall npm packages, we have to keep one important point in mind - are the packages installed locally or globally?
Depending on that, we uninstall npm packages.
How to Uninstall npm Packages Installed Locally
In any web application, there is a node_modules folder, where all the installed packages are. So, to uninstall npm packages, we must change our directory to that folder.
After doing that, running the following command will uninstall the package:
npm uninstall <package-name> |
Remember the package.json file that contained the name of all the packages used in a particular project?
Well, while uninstalling npm packages, we must remove them from the package.json file too. To do that, add -s or - -save to the command as shown below:
npm uninstall <package-name> -s |
OR
npm uninstall <package-name> --save |
How to Uninstall npm Packages Installed Globally
Now that we know how to uninstall locally installed npm packages uninstalling npm packages installed globally won’t be a problem.
The only difference in the syntax would be the addition of a -g or - -global flag.
npm uninstall -g <package-name> |
OR
npm uninstall --global <package-name> |