Premium lesson

Removing Installed npm Packages

npm·2 min read·Jan 1, 2025

Removing 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.

Removing global packages

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

icon light bulb key

Unlock the Build CLI Apps in JavaScript & Node.js module

Learn how to build, integrate, and safeguard scalable CLI tools, scripts, and apps with JavaScript, Node.js, npm, and Git.

You get immediate access to:

  • 45 focused lessons across JavaScript, Node.js, npm, and Git
  • 17 real-world projects with commented solutions
  • Ongoing updates to this bundle
  • Lifetime access to this bundle
Unlock this module