2txg9a
Last Updated: February 25, 2016
·
3.04K
· rafaelrosafu

How to setup nodejs on Centos 6 machine in 5 seconds

Quick and not so dirty way of setting up nodejs on a Centos machine without using packages, which are usually out of date and you need to add the EPEL repo. I'm not a node guy but I don't believe this is the recommended way of putting anything in production, but it's good for quick tests on VPSs, Vagrant machines and the like.

Just run the whole thing bellow, adjust the user name if you want, it's just a suggestion to avoid running as root.

# Create a new, non-root user
adduser node
echo "node ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
su - node

# Install git
sudo yum install git

# Install node.js through nave
cd ~
mkdir .nave
cd .nave
wget https://raw.github.com/isaacs/nave/master/nave.sh
sudo chmod +x nave.sh
sudo ln -s $PWD/nave.sh /usr/local/bin/nave
cd ~
nave install 0.10.15
nave use 0.10.15
node -v

After that, just clone your app repo and have fun:

# Run sample app
git clone <your node application repo>
cd my-node-app
npm install
node start-file.js