The Node Version Manager(nvm) could help you to manage multiple Node.js installations. The following steps are executed from root account.
1. Install the required packages.
apt-get install build-essential openssl libssl-dev curl
2. Create a new user group and add those users which are allowed to manage Node.js installation. The following command create a new group called dev.
3. Download the nvm source from GitHub to /opt/nvm.
git clone https://github.com/creationix/nvm.git /opt/nvm
4. Create the /usr/local/nvm directory which serves as the NVM_DIR and stores all the downloaded Node.js.
5. Create the /usr/local/node directory which serves as the NPM_CONFIG_PREFIX and stores all the Node Package Manager(npm) global files.
6. Make sure the dev group could access the 2 newly created folders.
chown -R root:dev /usr/local/nvm chmod -R 775 /usr/local/nvm chown -R root:dev /usr/local/node chmod -R 775 /usr/local/node
7. Create the /etc/profile.d/nvm.sh as follow. This file would be executed every time when any user is logged in.
export NVM_DIR=/usr/local/nvm source /opt/nvm/nvm.sh export NPM_CONFIG_PREFIX=/usr/local/node export PATH="/usr/local/node/bin:$PATH"
8. Open another SSH session and login as a user under the dev group. Verify the nvm installation as follow.
9. Install a specific version of Node.js.
nvm install 0.11
10. Verify the Node.js version.
11. Set your default Node.js version so it would be activate automatically when user is logged in.
nvm alias default 0.11
12. Or you can switch to any installed version by npm use.
nvm use 0.11