Open In App

Remove NPM - npm uninstall

Last Updated : 31 May, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

To remove npm (Node Package Manager) from your macOS system, you can't use npm uninstall since npm itself doesn't support uninstalling itself. Instead, you need to remove it manually along with Node.js.

What is NPM?

NPM is a package manager for the JavaScript programming language maintained by Microsoft's npm, Inc. npm is the default package manager for the JavaScript runtime environment Node.js and is included as a recommended feature in the Node.js installer.

What is NPM remove?

npm remove is a command-line interface (CLI) command provided by npm to uninstall packages from your Node.js project. Before removing, let's learn how to install packages using npm.

Installing a package using npm

To install a package using npm (Node Package Manager), you can follow these steps.

1. Open your Terminal or Command Prompt: Navigate to the directory of your Node.js project or create a new directory where you want to install the package.

2. Use the npm install command:

npm install <package_name> 
or
npm i <package_name>

Replace <package_name> with the name of the package you want to install.

Example: In this example we will install bycrypt package

npm i bcrypt
or
npm install bycrypt
Installing npm packages
installing bycrypt package using npm

Uninstalling a Package using npm

Use the npm uninstall command to remove any installed package:

npm uninstall <package_name> 

Replace <package_name> with the name of the package you want to remove.

Example: In this example we will install bycrypt package

npm uninstall bycrypt
Screenshot-2024-05-07-180311
uninstalling bcrypt

Remove npm

npm install 

macOS and Linux:

You can uninstall npm using the following command in the terminal:

sudo npm uninstall npm -g

This command removes npm globally from your system.

Windows:

npm uninstall npm -g

This command should be executed in a command prompt or PowerShell with administrator privileges.

Screenshot-2024-05-07-175331

Note: After executing the appropriate command for your operating system, npm should be successfully removed from your system. You can verify its removal by checking if npm commands no longer work in your terminal or command prompt.

Remove a Dev Dependency

To remove a dev dependency, you need to attach the "-D" or "--save-dev" flag to the npm uninstall and then add package name after it.

npm uninstall -D <package_name> 
or
npm uninstall --save-dev <package-name>

Example: In this example we will first install then uninstall nodemon dev dependency

Install:

npm uninstall -D nodemon
installing nodemon using npm
uninstall nodemon

Updated package.json file.

dependencies list
after installation

Uninstall:

npm uninstall -D nodemon
removing dev dependencies
uninstall nodemon

Next Article

Similar Reads