npm-uninstall
Remove installed npm packages
TLDR
Remove a package from the current project
Remove a package globally
Remove multiple packages at once
SYNOPSIS
npm uninstall [
PARAMETERS
The name of the package(s) to uninstall. Multiple packages can be specified, separated by spaces.
-g, --global
Uninstall the package(s) globally rather than locally.
--save
Remove the package(s) from the dependencies list in package.json.
--save-dev
Remove the package(s) from the devDependencies list in package.json.
--save-optional
Remove the package(s) from the optionalDependencies list in package.json.
--save-prod
Remove the package(s) from the dependencies list in package.json.
--no-save
Prevents saving to `dependencies`.
-f, --force
Force removal. Sometimes dependencies are deeply nested. Force allows you to bypass conflicts that arise.
DESCRIPTION
npm uninstall removes packages that are installed in the current project directory or globally. It deletes the specified packages from the node_modules folder and updates the package.json and package-lock.json files accordingly. You can uninstall a single package or multiple packages at once. If the --save, --save-dev, or --save-optional flags are used, npm will also remove the corresponding entry from the dependencies, devDependencies, or optionalDependencies sections of the package.json file. Uninstalling a package globally (using the -g flag) removes it from the global node_modules directory, making it unavailable to projects that depend on it. npm also automatically uninstalls the dependencies of the uninstalled package that are no longer required by other installed packages, cleaning up the node_modules directory.
CAVEATS
Be careful when uninstalling global packages as it can affect other projects that rely on them. Ensure you are in the correct project directory before running the command to avoid accidentally uninstalling packages from the wrong project. If there are dependency conflicts you can use --force to override them, but use with caution as it can break your project.
UNINSTALLING DEPENDENCIES
When a package is uninstalled, npm automatically analyzes the remaining packages and removes any dependencies that are no longer required by other installed packages. This helps to keep the node_modules directory clean and prevents unnecessary bloat.
PEER DEPENDENCIES
Note that uninstalling a package does not automatically uninstall its peer dependencies. These must be uninstalled explicitly if no other packages require them.
HISTORY
The `npm uninstall` command was introduced with the initial release of npm, designed to manage Node.js package dependencies. It evolved alongside npm itself, with features like save flags being added to simplify managing the `package.json` file. As npm grew in popularity, the command was refined to handle increasingly complex dependency trees and edge cases.
SEE ALSO
npm-install(1), npm(1), package.json(5)