DEV Community

loading...

Uninstalling npm packages

flavio ⚡️🔥
I write tutorials for developers at https://flaviocopes.com
Originally published at flaviocopes.com on ・1 min read

To uninstall a package you have previously installed locally (using npm install <package-name> in the node_modules folder, run

npm uninstall <package-name>
Enter fullscreen mode Exit fullscreen mode

from the project root folder (the folder that contains the node_modules folder).

Using the -S flag, or --save, this operation will also remove the reference in the package.json file.

If the package was a development dependency, listed in the devDependencies of the package.json file, you must use the -D / --save-dev flag to remove it from the file:

npm uninstall -S <package-name>
npm uninstall -D <package-name>
Enter fullscreen mode Exit fullscreen mode

If the package is installed globally , you need to add the -g / --global flag:

npm uninstall -g <package-name>
Enter fullscreen mode Exit fullscreen mode

for example:

npm uninstall -g webpack
Enter fullscreen mode Exit fullscreen mode

and you can run this command from anywhere you want on your system because the folder where you currently are does not matter.

Discussion (0)

Forem Open with the Forem app