npm uninstall Explained
What npm uninstall does, with an example.
Published November 11, 2026
npm uninstall removes a package from node_modules and from package.json (and the lockfile). Use -g for global packages.
How it works
It also removes dependencies that nothing else needs. Aliases: npm remove, npm rm.
Clean leftover unused packages with npm prune.
Try it
npm uninstall lodash
removed 1 package
npm prune
removed 3 extraneous packages
Practical examples
Remove a package
npm uninstall lodashRemove a dev dependency
npm uninstall -D jestGlobal
npm uninstall -g typescriptClean extraneous
npm pruneCommon mistakes
- Deleting folders manually and leaving package.json entries.
- Uninstalling packages that other code still imports.
- Forgetting to remove imports.
Key takeaways
- npm uninstall removes a package from node_modules and from package.json (and the lockfile).
- Run npm help <command> for every option.
- Commit package-lock.json.
FAQ
Remove without editing package.json?
npm uninstall --no-save lodash.
Does this work with yarn or pnpm?
They have equivalents with similar commands.