install

npm uninstall

Removes a package from node_modules and drops it from the matching section of package.json and the lockfile. Aliases: `remove`, `rm`, `r`, `un`.

npm uninstall <pkg> [<pkg>...] [--save-dev|--global|--no-save]

Common flags

Flag Purpose
--save-dev (-D) Remove specifically from devDependencies
--save-optional (-O) Remove from optionalDependencies
--global (-g) Uninstall a globally-installed package
--no-save Remove from node_modules but leave package.json unchanged

Examples

npm uninstall lodash

Remove lodash from the project and lockfile

npm rm -D @types/node

Alias to remove a devDependency

npm uninstall -g nodemon

Remove a globally-installed CLI

Gotcha

If a package appears in multiple dependency sections, npm removes it from all of them unless you pass a specific --save-* flag. After large removals, run `npm install` to prune orphaned nested deps from the tree.

Related commands

← All npm commands · npm vs pnpm vs Yarn · Fix Node OOM