Update Node.js version to V6 from V5 (CentOS)

Background

I have been using Node V5 inside the AWS EC2.

This time I need to update it but I got in problem, this is the memo how I solved it.

Environments

  • AWS EC2
  • ElasticBeanstalk
  • Centos

The Problem

I need to update to Node V6 from V5, so I tried to yum install the Node from the new repository.

The yum keep using the old repository and does not use the new one, even I registered the new V6 repository for install.

The reason was yum’s cache keep holding the old repository so that I couldn’t update it.

What I needed to do is to clear the yum’s cache first.

# Remove old nodejs
sudo su -
yum remove -y nodejs

# Remove old cache
rm -rf /etc/yum.repos.d/nodesource-el.repo
rm -fr /var/cache/yum/*
yum clean all

# Install Node v6
curl -sL https://rpm.nodesource.com/setup_6.x | bash -
yum install -y nodejs

Reference

@takp