Open In App

How to Completely Uninstall Node.js & Reinstall from Beginning (Mac OS X) ?

Node.js is a widely adopted and robust platform that allows software engineers to create high-performance and scalable web applications with ease. However, there might be instances where you need to perform a complete uninstallation of Node.js from your Mac OS X system and start anew. This necessity could arise due to various factors, such as outdated versions, conflicts with other software programs, or simply the desire for a fresh start.

Uninstalling Node.js

Before we embark on the reinstallation journey, verifying that Node.js has been entirely removed from our system is imperative. Follow these steps to achieve a complete uninstallation:

Step 1: To verify if Node.js is installed on your device and to check its version, follow these steps. Open the terminal and enter the command. This will display the installed version of Node.js. If a version number appears, then Node.js is installed. However, if it doesn’t show any version, you should move on to the next step.



node -v

Step 2: Remove Node.js Executable. Delete the Node.js executable by entering the following command in the terminal.After that you will be prompted to authenticate the command by entering your password.

sudo rm /usr/local/bin/node

Step 3: Delete npm Executable. Next, remove the npm executable using this command. This command erases the npm executable from the system.

sudo rm /usr/local/bin/npm

Step 4: Eliminate Node.js Modules. Lastly, remove all Node.js modules and packages. In the terminal, type. This command clears all Node.js modules and packages from the system.

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

Reinstalling Node.js

Step 1: Install Homebrew. Homebrew simplifies software installation and management on Mac. To install Homebrew, execute the following command in the terminal. The below command installs Homebrew on your system.

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

Step 2: After entering the password execution starts.

After completion

Step 3: To install Node.js using Homebrew, ensure Homebrew is installed and then use the following command in the terminal:

brew install node

Step 4: Verify Installation. To ensure Node.js and npm are correctly installed, enter the following commands in the terminal. These commands display the installed versions of Node.js and npm, respectively. If you see version numbers, it means that Node.js and npm are installed correctly on your system.

node -v
npm -v

Conclusion

In this article, we’ve provided a comprehensive guide on completely uninstalling Node.js from your Mac OS X system and reinstalling it from scratch. Following these steps ensures a fresh and up-to-date installation of Node.js, devoid of any conflicts or outdated versions. We trust that this guide has proven beneficial to you, and we wish you the best of luck in your Node.js development endeavors!

Article Tags :