#!/bin/bash

export NVM_DIR="$HOME/.nvm"

if [ -d "$NVM_DIR" ];then
  #prepare to run nvm
  [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
  cd $NVM_DIR

  #Uninstall NodeJS
  nvm deactivate
  nvm uninstall default || error "Failed to purge Node.JS!"
fi

#Remove nvm
sudo rm -rf "$NVM_DIR" ~/.npm ~/.bower
# Remove nvm initialisation script
sudo rm -f  ~/.node_bashrc
#remove nvm stuff from bashrc
sed -i '/node_bashrc/d' ~/.bashrc
