by Sai gowtham

How to remove all globally installed npm modules

In this tutorial, we are going to learn about how to remove all globally installed npm modules from your system.

Removing specific npm module

To remove a specific npm module, you need to run npm uninstall -g command followed by the module name.

Here is an example that removes the globally installed react module.

npm uninstall -g react

Removing all npm modules

To remove all npm modules from your system, you can use the following command.

npm ls -gp --depth=0 | awk -F/ '/node_modules/ && !/\/npm$/ {print $NF}' | xargs npm -g rm

This above command scans all globally installed npm modules and removes each module by running npm -g rm

Note: This above command works on Linux, macOS and anywhere you are using Linux environment.

For windows, you need to open the following folder and delete all contents present in that folder.

C:\Users\username\AppData\Roaming\npm

or you can open that folder by searching the following path inside the explorer.

%appdata%/npm

Top Udemy Courses

JavaScript - The Complete Guide 2020 (Beginner + Advanced)
JavaScript - The Complete Guide 2020 (Beginner + Advanced)
45,614 students enrolled
52 hours of video content
View Course
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
284,472 students enrolled
40 hours of video content
View Course
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
130,921 students enrolled
48.5 hours of video content
View Course