Trying to figure out how to uninstall a local or global NPM package?

In this article, we'll cover how to uninstall both local and globabl NPM packages during the development process.

Let's get started!

Table Of Contents

Uninstall Local Packages

To uninstall a package that was installed locally (using npm install <package> and stored in the node_modules directory for a specific project), use this command:

      npm uninstall <package>

After that command is run, the package will no longer be in your node_modules folder.

To also remove the package from the dependencies list in your package.json file, you can add either the --save flag to the command:

      npm uninstall <package> --save

Or the -S flag:

      npm uninstall -S <package>

If the package is a devDependency, you can remove it from the package.json file with the --save-dev flag:

      npm uninstall <package> --save-dev

Or the -D flag:

      npm uninstall -D <package>
Build A Hacker News Clone
Learn how to build and deploy a full-stack, production-ready application with React.js, Node.js, and MongoDB.
View Course

Uninstall Global Packages

Last, you can remove any NPM package you've installed globally with the -g flag:

      npm uninstall -g <package>

The global uninstall command will work from wherever you call it on your machine.

There you have it! As always, thanks for reading and happy coding!