Skip to content

Instantly share code, notes, and snippets.

@teocci
Last active February 24, 2024 17:00
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teocci/5ac7c3b59e255f414185b677717e620b to your computer and use it in GitHub Desktop.
Save teocci/5ac7c3b59e255f414185b677717e620b to your computer and use it in GitHub Desktop.
Installing Node.js in CentOS 7

Install NodeJS 16.17

sudo yum install -y gcc-c++ make curl
curl -sL https://rpm.nodesource.com/setup_16.x | sudo -E bash -

sudo yum list available nodejs
sudo yum install -y nodejs
node -v
npm -v

Node.js LTS

sudo yum install -y gcc-c++ make curl
curl -sL https://rpm.nodesource.com/setup_lts.x | bash -
# Remove old version
yum remove -y nodejs npm
# Clear cache
yum clean all
# Install new Node.js
yum install -y nodejs

Remove NodeJS

sudo yum remove -y nodejs
sudo rm -rf /var/cache/yum
sudo rm /etc/yum.repos.d/nodesource*
sudo yum clean all

Remove residual files

whereis node
sudo rm -rfv /usr/bin/node /usr/local/bin/node /usr/share/man/man1/node.1.gz
sudo rm -rfv /usr/bin/npm /usr/local/bin/npm /usr/share/man/man1/npm.1.gz
sudo rm -rfv /usr/local/bin/npx
sudo rm -rfv /usr/local/lib/node*
sudo rm -rfv /usr/local/include/node*
sudo rm -rfv /usr/lib/node_modules/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment