How to remove nodejs from nodesource.com?

First you can purge nodejs and its related files

sudo apt-get purge nodejs

then you can delete the its repositoy

sudo rm -r  /etc/apt/sources.list.d/nodesource.list

As addition, you may want to remove nodesource key.

First you can see:

sudo apt-key list

And it will output something look like this

pub   4096R/68576280 2014-06-13
uid                  NodeSource <[email protected]>
sub   4096R/AA01DA2C 2014-06-13

Then you can delete with:

sudo apt-key del 68576280

sudo apt-get purge nodejs

But this won't delete the /usr/lib/node_modules directory as its not empty.

So for a complete clean up, run:

sudo rm -r /usr/lib/node_modules/
sudo rm /etc/apt/sources.list.d/nodesource.list