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:
-
Remove the package from the
node_modulesdirectory. -
Remove the package from the
dependencies,devDependencies, andpeerDependenciesobjects of thepackage.jsonfile. -
Update the
package-lock.jsonfile 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.
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