Skip to content

Uninstalling npm packages with `npm uninstall`

New Course Coming Soon:

Get Really Good at Git

How to uninstall an npm Node package, locally or globally

To uninstall a package you have previously installed locally (using npm install <package-name> in the node_modules folder, run

npm uninstall <package-name>

from the project root folder (the folder that contains the node_modules folder).

This operation will also remove the reference in the package.json file.

If the package was a development dependency, listed in the devDependencies of the package.json file, you must use the -D / --save-dev flag to remove it from the file:

npm uninstall -D <package-name>

If the package is installed globally, you need to add the -g / --global flag:

npm uninstall -g <package-name>

for example:

npm uninstall -g webpack

and you can run this command from anywhere you want on your system because the folder where you currently are does not matter.

Are you intimidated by Git? Can’t figure out merge vs rebase? Are you afraid of screwing up something any time you have to do something in Git? Do you rely on ChatGPT or random people’s answer on StackOverflow to fix your problems? Your coworkers are tired of explaining Git to you all the time? Git is something we all need to use, but few of us really master it. I created this course to improve your Git (and GitHub) knowledge at a radical level. A course that helps you feel less frustrated with Git. Launching Summer 2024. Join the waiting list!
→ Get my Node.js Handbook
→ Read my Node.js Tutorial on The Valley of Code

Here is how can I help you: