Open In App

How to remove all Global Modules in Node.js ?

Node.js is an open-source and cross-platform runtime environment for executing JavaScript code outside of a browser. You need to remember that Node.js is not a framework and it’s not a programming language. Most of the people are confused and understand it’s a framework or a programming language. We often use Node.js for building back-end services like APIs like Web App or Mobile App. It is used in production by large companies such as Paypal, Uber, Netflix, Wallmart, and so on.

We can remove all the module globally in Node.js by the following ways:



For Linux (Ubuntu) users: In order to uninstall the globally installed package_name package, the following command can be used (using sudo if necessary, depending on your setup and permissions).

sudo npm rm --global package_name

To check whether the package is installed globally or not, use below command:



npm ls --global packae_name

Below images display the use of above command to uninstall express package globally:

For Window users: The Windows user can remove all the Node.js modules globally by just deleting the content of the following directory:

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

Steps to remove Global Modules:

  1. Press win + r (win = Windows button) from keyboard and a dialog box will appear as shown below:
  2. Now type %appdata%/npm in the text field and press enter button as shown below:

    The directory will have files and folders as shown below:

  3. Now delete the content of this directory.

All the global node modules are removed properly.

Article Tags :