How to Completely Uninstall Nodejs, and Reinstall From Scratch on Mac OS X?
To completely uninstall Nodejs and reinstall it from scratch on Mac OS X, follow these steps:
Open the Terminal application.
Run the command below to uninstall Nodejs:
sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/npm*
This command will remove all Nodejs-related files and directories.
Run the command below to remove any remaining Nodejs-related files:
sudo rm -rf /usr/local/bin/node /usr/local/include/node /usr/local/lib/node_modules
Close the Terminal application.
Download the Node.js package from the official Nodejs website (https://nodejs.org/en/download/).
Open the downloaded package and follow the installation instructions.
Verify that Nodejs has been installed correctly by running the command below in the Terminal application:
node -v
This command should output the version of Nodejs that you just installed.
Congratulations! You have successfully uninstalled and reinstalled Nodejs from scratch on your Mac OS X computer.