Dev

By Carlos Santana on
Reading time: 3 minutes

Nodejs-Bv4YU.png

In this post, I'll show you how to install and uninstall Node.js in Mac, Linux (Ubuntu), and Windows.

Installing Node.js on Mac

To install Node.js on Mac you just need to go to https://nodejs.org and then select the version you want to download, you have two choices: LTS Version and the Latest version, will depend on your needs, but personally, I always prefer to install the latest one for my development environment.

At this moment the versions you will find are:

Once you installed you can verify the version of your Node.js and NPM by doing:

node -v

npm -v

Installing Node.js on Ubuntu

You can install Node.js by using a PPA (Personal Package Archive).

cd ~
curl -sL https://deb.nodesource.com/setup_11.x -o nodesource_setup.sh

Then run the script under sudo:

sudo bash nodesource_setup.sh

Now you can install Node.js with the command: 

sudo apt install nodejs

Then you can verify your version by doing:

nodejs -v
npm -v

Installing Node.js on Windows

The Node.js installation on Windows is very similar to Mac, you just need to download the installation file from the official website, if you want to see all the available downloads for all the Operating Systems you can go to https://nodejs.org/en/download/current/.

Uninstall Node.js from Mac

To uninstall Node.js completely from your Mac you need to follow these commands:

lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do  sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*

cd /usr/local/lib
sudo rm -rf node*

cd /usr/local/include
sudo rm -rf node*

cd /usr/local/bin
sudo rm -rf /usr/local/bin/npm
sudo rm -rf /usr/local/bin/node

sudo rm -rf /usr/local/share/man/man1/node.1
sudo rm -rf /usr/local/lib/dtrace/node.d
sudo rm -rf ~/.npm

Uninstall Node.js from Ubuntu

To uninstall Node.js on Ubuntu you need to run these commands:

sudo apt-get remove nodejs
sudo apt-get remove npm

Then go to /etc/apt/sources.list.d and remove any node list if you have. Then do:

Only members can see all the codes
You can Login or Sign Up

Finally, check for any .npm or .node folder in your home folder and delete those.

I hope this post is useful to you. If you want to join our Slack community you can do it here.

avatarLeave a comment

Your comment

Only members can comment. You can Login or Sign Up