Skip to content

Instantly share code, notes, and snippets.

@kedar2a
Last active May 23, 2022 17:06
Show Gist options
  • Save kedar2a/f6a8b50eb4c48fe1787e1e98f7dff987 to your computer and use it in GitHub Desktop.
Save kedar2a/f6a8b50eb4c48fe1787e1e98f7dff987 to your computer and use it in GitHub Desktop.
nodejs: Removing and installing

Removing existing node, nodejs and npm (if installed previously):

  • apt-get remove nodejs npm node
  • sudo apt-get purge nodejs npm node
  • sudo rm -rvf /usr/local/bin/npm /usr/local/share/man/man1/node* /usr/local/lib/dtrace/node.d ~/.npm ~/.node-gyp /opt/local/bin/node opt/local/include/node /opt/local/lib/node_modules
  • sudo rm -rfv /usr/local/lib/node*
  • sudo rm -rfv /usr/local/include/node*
  • sudo rm -rfv /usr/local/bin/node*

For stable nodejs version v0.10.*

  1. sudo add-apt-repository ppa:chris-lea/node.js
  2. sudo apt-get update
  3. sudo apt-get install python-software-properties python g++ make nodejs

For latest nodejs version:

  1. sudo apt-get install npm
  2. sudo npm cache clean OR sudo npm cache vefify
  3. sudo npm install -g n
  4. sudo n latest
  5. ln -sf /usr/local/n/versions/node/<version no from above step>/bin/node /usr/bin/node
@phamtho123
Copy link

after removing with the command "sudo rm -rf /usr/local/bin/node*" to reinstall nodejs, what command do you use

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment