Last active
December 10, 2015 10:59
-
-
Save nimasmi/5a0311023168481a4d22 to your computer and use it in GitHub Desktop.
Vagrant provision—Node installation snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
NODE_VERSION=v4.2.3 # amend this line only, to change Node version | |
# Node.js | |
if ! command -v npm; then | |
INSTALL_NODE=1 | |
elif [ $NODE_VERSION != `node --version` ]; then | |
rm -rf /opt/node-`node --version`-linux-x64/ | |
rm /usr/local/bin/node | |
rm /usr/local/bin/npm | |
INSTALL_NODE=1 | |
else | |
INSTALL_NODE=0 | |
fi | |
if [ $INSTALL_NODE = 1 ]; then | |
wget http://nodejs.org/dist/$NODE_VERSION/node-$NODE_VERSION-linux-x64.tar.gz | |
cd /opt && tar -xzf /home/vagrant/node-$NODE_VERSION-linux-x64.tar.gz | |
ln -s /opt/node-$NODE_VERSION-linux-x64/bin/node /usr/local/bin/node | |
ln -s /opt/node-$NODE_VERSION-linux-x64/bin/npm /usr/local/bin/npm | |
cd /home/vagrant | |
rm node-$NODE_VERSION-linux-x64.tar.gz | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment