Uninstall Node.js on a Mac OS

Uninstall Node.js on a Mac OS

If you have node.js or npm installed in your mac system. And you want to uninstall node.js and npm in your Mac OS system for some reason. In this tutorial, we will show you 3 solutions to uninstall Node.js from Mac OS system.

How to Uninstall Node.js on a Mac

Here are the 3 solutions on how to uninstall Node.js on a Mac:

  • Solution 1: Uninstall Node.js using Terminal
  • Solution 2: Uninstall Node.js using Homebrew
  • Solution 3: Uninstall Node.js using Node Version Manager (NVM)

Solution 1: Uninstall Node.js using Terminal

One of the easiest and quickest ways to uninstall Node.js from your Mac is by using the Terminal app. Here are the steps to do so:

Step 1: Open the Terminal app on your Mac.

Step 2: Type the following command and press Enter to see the version of Node.js that is installed on your Mac:

node -v

Step 3: Type the following command to uninstall Node.js:

sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/man1/node.1}

Here’s a breakdown of what each part of the command means:

  • sudo – this prefix grants the user superuser permissions, allowing the command to perform actions that require administrative privileges.
  • rm – this command stands for “remove” and is used to delete files and directories.
  • -rf – these flags indicate that the removal should be recursive and forceful, meaning that it will delete everything within the specified directories, including any subdirectories and their contents, without prompting for confirmation.
  • /usr/local/ – this is the directory where Node.js is typically installed on a Mac.
  • {bin/{node,npm},lib/node_modules/npm,lib/node,share/man/man1/node.1} – this is a list of directories and files that should be deleted.

Breaking down the curly braces, we can see that there are three directories within the /usr/local/ directory that should be removed: bin/, lib/node_modules/npm/, and lib/node/. Within the bin/ directory, two files should be removed: node and npm. Additionally, the share/man/man1/node.1 file, which contains Node.js manual pages, should be removed.

Overall, this command is a quick and effective way to completely uninstall Node.js and its associated files from a Mac. However, it should be used with caution, as it can also delete other important files if used improperly.

Step 4: Press Enter and enter your password when prompted.

Step 5: Type the following command and press Enter to verify that Node.js has been uninstalled:

node -v

If Node.js has been successfully uninstalled, you should see the following message: “command not found.”

Solution 2: Uninstall Node.js using Homebrew

If you installed Node.js on your Mac using Homebrew, you can uninstall it using Homebrew as well. Here are the steps to do so:

Step 1: Open the Terminal app on your Mac.

Step 2: Type the following command to uninstall Node.js:

brew uninstall node

Step 3: Press Enter and wait for the uninstallation process to complete.

Step 4: Type the following command and press Enter to verify that Node.js has been uninstalled:

node -v

If Node.js has been successfully uninstalled, you should see the following message: “command not found.”

Solution 3: Uninstall Node.js using Node Version Manager (NVM)

If you installed Node.js using Node Version Manager (NVM), you can uninstall it using the following steps:

Step 1: Open the Terminal app on your Mac.

Step 2: Type the following command to list the installed versions of Node.js:

nvm ls

Step 3: Type the following command to uninstall a specific version of Node.js:

nvm uninstall <version>

Replace <version> with the version of Node.js that you want to uninstall.

Step 4: Repeat Step 3 for each version of Node.js that you want to uninstall.

Step 5: Type the following command to verify that Node.js has been uninstalled:

node -v

If Node.js has been successfully uninstalled, you should see the following message: “command not found.”

Conclusion

In conclusion, Node.js is a widely used JavaScript runtime that can be uninstalled from a Mac using several methods. The easiest and quickest way is to use the terminal or homebrew to uninstall Node.js and its associated files. If you installed Node.js using Homebrew, you can use Homebrew to uninstall it. Finally, if you installed Node.js using Node Version Manager (NVM), you can use NVM to uninstall it.

Recommended Tutorials

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *