-
-
Save nmvuong92/d24534cd8ba636ac546f790ae4600fff to your computer and use it in GitHub Desktop.
Install nvm and NodeJS using AWS EC2 user data script
This file contains 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 | |
apt-get -y update | |
cat > /tmp/subscript.sh << EOF | |
# START UBUNTU USERSPACE | |
echo "Setting up NodeJS Environment" | |
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.9/install.sh | bash | |
echo 'export NVM_DIR="/home/ubuntu/.nvm"' >> /home/ubuntu/.bashrc | |
echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> /home/ubuntu/.bashrc | |
# Dot source the files to ensure that variables are available within the current shell | |
. /home/ubuntu/.nvm/nvm.sh | |
. /home/ubuntu/.profile | |
. /home/ubuntu/.bashrc | |
# Install NVM, NPM, Node.JS & Grunt | |
nvm install --lts | |
nvm ls | |
EOF | |
chown ubuntu:ubuntu /tmp/subscript.sh && chmod a+x /tmp/subscript.sh | |
sleep 1; su - ubuntu -c "/tmp/subscript.sh" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment