How to Completely Uninstall Node.js in MacOS

Isaac Tony Feb 02, 2024
  1. Use Homebrew to Uninstall Node.js in MacOS
  2. Use NVM to Uninstall Node.js in MacOS
  3. Manually Uninstall Node.js in MacOS
How to Completely Uninstall Node.js in MacOS

Node.js is an open-source server-side JavaScript runtime environment built on Chrome’s V8 JavaScript engine.

Node.js is suitable for creating scripts that generate and render dynamic content and read, open, and close files on the server.

We can use multiple ways to install Node.js regardless of the operating system. Similarly, there are a couple of ways that we can also use to get rid of Node.js from our system.

This article will explore how to uninstall Node.js from macOS systems.

Use Homebrew to Uninstall Node.js in MacOS

Now, this is perhaps the simplest way of removing software from machines running on macOS.

Homebrew is a free package manager that allows us to install, uninstall, and update software from macOS systems by running commands in the terminal.

To install Homebrew, we first need the support of XCode command-line tools that we can easily install by running the command below in the terminal.

xcode-select --install

xCode

Click install to proceed. We can run the command below to install Homebrew for macOS 10.13, macOS10.12, and 10.11.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

We can use this command to install Homebrew for version 11 or BigSur, macOS 10.14, and macOS 10.4.

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

Once Homebrew is installed, we can uninstall Node.js and its components from our system using the command below.

$ brew uninstall node

Use NVM to Uninstall Node.js in MacOS

The Node Version Manager is another helpful package for managing multiple versions on UNIX-like systems, macOS included. Besides allowing us to also switch between multiple versions, we can remove pre-existing installations of Node.js.

If we already know the Node.js version installed in your system, you can uninstall Node.js by specifying the version number below.

$ nvm uninstall <version>

A more extensive approach to uninstall Node.js, which eventually leads to the same solution, is as follows. Begin by running the command below to remove /.nvm/*/bin from $PATH.

$ nvm deactivate

If you’re running multiple versions of Node.js, we also need to verify the exact version that we want to uninstall from our system. The command below lists all the versions of Node.js that are currently installed in your system

$ nvm list

Once we are sure of the version of Node.js that we want to uninstall, we can execute the command below.

$ nvm uninstall <version>

Manually Uninstall Node.js in MacOS

It is the least recommended way to adopt when uninstalling Node.js alongside the npm package from a macOS machine.

As the name suggests, this method involves manually locating directories containing node packages, files, and modules and deleting them from the system.

To a large extent, this method relies on the installation method used when installing Node.js and is more effective if Node.js was installed using macOS Binary (.tar.gz).

Most Node.js installation files and modules are located in the home directory and in the following folders /usr/local/lib, /usr/local/include. However, after deleting all files related to Node.js, this can be quite challenging.

Here are some of the folders you might have to check out for Node.js folders and modules that need to be deleted.

The main directory.
/usr/local/lib
/usr/local/include
/opt/local/include)
/opt/local/bin/)
/usr/local/share/doc/
/opt/local/lib/
/usr/local/share/systemtap/tapset/
/usr/local/lib/dtrace/
/usr/local/share/man/man1
/usr/local/share/man/man1
Author: Isaac Tony
Isaac Tony avatar Isaac Tony avatar

Isaac Tony is a professional software developer and technical writer fascinated by Tech and productivity. He helps large technical organizations communicate their message clearly through writing.

LinkedIn