Removing Node.js on Mac using Homebrew: A Step-by-Step Guide

Easily remove Node.js from your Mac using Homebrew with this step-by-step guide. Learn how to uninstall, clean up residual files, and verify removal.

Get Started free
Removing Node.js on Mac using Homebrew A Step-by-Step Guide
Home Guide Removing Node.js on Mac using Homebrew: A Step-by-Step Guide

Removing Node.js on Mac using Homebrew: A Step-by-Step Guide

Node.js is a powerful and widely used JavaScript runtime that enables developers to build scalable and efficient applications. However, there may be instances where you need to uninstall it from your Mac.

If you originally installed Node.js using Homebrew, removing it is a quick and straightforward process. This guide will take you through each step to ensure a clean and complete uninstallation.

Steps to Uninstall Node.js on Mac using Homebrew

Follow these steps to completely uninstall Node.js from your Mac using Homebrew:

Step 1: Uninstall Node.js Using Homebrew

To remove Node.js, open the Terminal and run the following command:

brew uninstall node
Copied

This command will remove Node.js from your MAC system.

Step 2: Verify Node.js Removal

After running the uninstall command, confirm that Node.js has been removed by checking its version:

node -v
Copied

If Node.js has been successfully uninstalled, this command will return an error or indicate that the command has not been found.

Step 3: Clean Up Residual Files

Even after uninstalling Node.js, some residual files and configurations may still be present. To remove them, run:

brew cleanup
Copied

This command clears unnecessary files and dependencies left behind by Homebrew.

Step 4: (Optional) Remove Dependencies or Global Packages

If you installed global packages using npm, you may want to remove them as well. Run:

rm -rf ~/.npm

rm -rf /usr/local/lib/node_modules
Copied

This step ensures that no outdated or unnecessary Node.js related files remain.

Step 5: Verify Complete Uninstallation

To make sure Node.js is fully removed, restart your terminal and check again using:

node -v

npm -v
Copied

If you plan to rebuild or test a Node.js application, BrowserStack Automate provides a seamless way to run tests across different browsers and devices without worrying about local environment configurations. This allows you to focus on development while ensuring compatibility and performance across real-user conditions.

BrowserStack Automate Banner

Other Methods to Uninstall Node.js on Mac

Here are some other methods to uninstall Node.js:

Uninstall Node.js Using NVM (Node Version Manager)

If you installed Node.js with NVM (Node Version Manager), follow these steps to remove it:

1. Check if NVM is installed

If you don’t have NVM, install it by following the steps on the official NVM GitHub page.

2. Restart your terminal

Open a new Terminal or restart your current one to load NVM properly.

3. List installed Node.js versions

Run this command to see all installed Node.js versions:

nvm ls
Copied

4. Uninstall Node.js

To remove a specific version, use:

nvm uninstall <version>
Copied

Example:

nvm uninstall 14.17.3

Manual Uninstallation of Node.js

If you installed Node.js manually (not using NVM or Homebrew), follow these steps to remove it completely:

1. Remove Node.js binaries

Open Terminal and run:

sudo rm -rf /usr/local/bin/node  

sudo rm -rf /usr/local/include/node  

sudo rm -rf /usr/local/lib/node_modules
Copied

2. Delete additional Node.js files

Run the following commands to remove any leftover files:

sudo rm -rf ~/.npm  

sudo rm -rf ~/.node-gyp  

sudo rm -rf /usr/local/share/man/man1/node*  
Copied

Verifying Node.js Removal

After uninstalling Node.js, you can check if it has been completely removed from your MAC system by running:

node -v  

npm -
Copied

If Node.js is successfully uninstalled, you should see a “command not found” message for both commands.

Reinstalling Node.js (If Needed)

If you need to reinstall Node.js after uninstalling it, follow these simple steps:

Step 1: Install Homebrew

Homebrew is a package manager for macOS that makes it easy to install and manage any software. To install Homebrew, open the Terminal and run the following command:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Copied

This will install Homebrew on your system.

Step 2: Install Node.js

Once Homebrew is installed, use it to install Node.js by running this command:

brew install node
Copied

This will download and install the latest version of Node.js on your system.

Step 3: Verify the Installation

To make sure Node.js and npm are installed correctly, run these commands in the Terminal:

node -v  

npm -
Copied

You should see the version numbers for both Node.js and npm. If they appear, Node.js is successfully installed.

Conclusion

Uninstalling Node.js on a Mac using Homebrew is quick and easy. Following the steps in this guide, you can remove Node.js and its related files completely. If you ever need to reinstall it, Homebrew makes the process simple.

If you plan to rebuild or test a Node.js application, BrowserStack Automate is an excellent choice for cross-browser testing. It provides access to 3500+ real browsers and devices, allowing you to ensure seamless functionality across different environments without the hassle of local setup.

It supports parallel testing to speed up execution, integrates seamlessly with CI/CD pipelines, and provides in-depth debugging tools. By leveraging BrowserStack, you can ensure your application performs consistently across different platforms, accelerating development and improving overall software quality.

Talk to an Expert

Tags
Automation Testing Testing Tools Types of Testing