To uninstall one or more locally installed packages, use:
npm uninstall <package name>
The uninstall command for npm has five aliases that can also be used:
npm remove <package name>
npm rm <package name>
npm r <package name>
npm unlink <package name>
npm un <package name>
If you would like to remove the package from the package.json
file as part of the uninstallation, use the --save
flag (shorthand: -S
):
npm uninstall --save <package name>
npm uninstall -S <package name>
For a development dependency, use the --save-dev
flag (shorthand: -D
):
npm uninstall --save-dev <package name>
npm uninstall -D <package name>
For an optional dependency, use the --save-optional
flag (shorthand: -O
):
npm uninstall --save-optional <package name>
npm uninstall -O <package name>
For packages that are installed globally use the --global
flag (shorthand: -g
):
npm uninstall -g <package name>