uninstall node js from mac

How to Uninstall Node.js from a Mac

If you are a developer and have been working with Node.js for a while, you may need to uninstall it for some reason. In this article, I will explain how to uninstall Node.js from a Mac in a few simple steps.

Step 1: Check the Version of Node.js Installed

The first step before uninstalling Node.js is to check which version of Node.js is currently installed on your Mac. To do this, open the terminal and run the following command:

$ node -v

This will display the current version of Node.js installed on your Mac.

Step 2: Uninstall Node.js using Terminal

The easiest way to uninstall Node.js from a Mac is by using the terminal. Open the terminal and run the following command:

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

This command will remove all the files associated with Node.js from your Mac. Note that, you need to have administrative privileges to execute this command.

Step 3: Verify if Node.js is Uninstalled

After running the above command, Node.js should be uninstalled from your Mac. To verify if it is uninstalled, open the terminal and run the following command:

$ node -v

If Node.js is uninstalled properly, you should see an error message saying "command not found".

Alternative Way

If you have installed Node.js using a package manager like Homebrew or MacPorts, you can uninstall it using those package managers. For example, if you have installed Node.js using Homebrew, you can run the following command to uninstall it:

$ brew uninstall node

This command will remove Node.js and its dependencies installed by Homebrew.

Conclusion

Uninstalling Node.js from a Mac is a simple process that can be done in a few steps. If you encounter any issues while uninstalling Node.js, feel free to leave a comment below.

Subscribe to The Poor Coder | Algorithm Solutions

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
[email protected]
Subscribe