How Can I Uninstall Node.js And Perform A Fresh Installation Starting From Scratch On Mac OS X?

To completely uninstall Node.js and reinstall it from scratch on macOS, you can follow these steps:

Step 1: Uninstalling Node.js

  1. Open Terminal.app
  2. Run the following command to remove Node.js and npm:
sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}
  1. Enter your macOS password when prompted.

Step 2: Removing Node.js environment variables

  1. Open Terminal.app
  2. Run the following command to remove any Node.js-related environment variables from your shell configuration file (e.g., .bashrc, .bash_profile, .zshrc, etc.):
sudo nano ~/.bashrc
  1. Remove any lines referencing Node.js or npm.
  2. Save and exit the file by pressing Control + X, then Y, and finally Enter.

Step 3: Reinstalling Node.js

  1. Download the latest Node.js package from the official website (https://nodejs.org).
  2. Open the downloaded package (.pkg) file.
  3. Follow the installation wizard to install Node.js.

Step 4: Confirming installation

  1. Open Terminal.app
  2. Run the following command to confirm that Node.js and npm are installed correctly:
node -v
npm -v
  1. You should see the versions of Node.js and npm displayed, indicating successful installation.

That’s it! You have now completely uninstalled Node.js and reinstalled it from scratch on your macOS system.

About the Author Rex

I'm a passionate tech blogger with an insatiable love for programming! From my early days tinkering with code, I've delved into web dev, mobile apps, and AI. Sharing insights and tutorials with the world is my joy, connecting me to a global community of like-minded tech enthusiasts. Python holds a special place in my heart, but I embrace all challenges. Constantly learning, I attend tech conferences, contribute to open-source projects, and engage in code review sessions. My ultimate goal is to inspire the next generation of developers and contribute positively to the ever-evolving tech landscape. Let's code together!