Remove Installed npm Packages

npm·2 min read·Jan 1, 2025

Remove local packages

To completely remove unneeded packages from a project, you can use the npm uninstall command:

$ npm uninstall package ...

Where package ... is a list of package names.

When executed, it will:

  1. Remove the package from the node_modules directory.
  2. Remove the package from the dependencies, devDependencies, and peerDependencies objects of the package.json file.
  3. Update the package-lock.json file to reflect those changes in the dependency tree of the project.

Remove global packages

To uninstall a global package, you can use the npm uninstall command with the -g flag.

$ npm uninstall -g <package ...>

This will remove the package from the global npm installation directory.

Clean up unused dependencies

To remove any unused or unreferenced dependencies from the node_modules directory, to free up disk space and improve the performance of your application, you can use the npm prune command:

$ npm prune

Unlock the program 🚀

Pay once, own it forever.

€79

30-day money-back guarantee

  • 13 modules
  • 113 lessons with full-code examples
  • 29 projects with commented solutions
  • All future lesson and project updates
  • Lifetime access

By submitting this form, you agree to the Terms & Conditions and Privacy Policy.