Skip to content

Instantly share code, notes, and snippets.

@yuhonas
Created February 5, 2018 03:50
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save yuhonas/21d0b4797956ecbb0717dbe9bd00beca to your computer and use it in GitHub Desktop.
Save yuhonas/21d0b4797956ecbb0717dbe9bd00beca to your computer and use it in GitHub Desktop.
Install node & yarn on amazon linux
#!/usr/bin/env bash
# References
# -------------
# https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html#w2ab1c23b7c10
# https://gist.github.com/sealocal/0cd468ba4f12cdada436aebe534b40da
set -xe
NODE_VERSION=v9.3.0
YARN_REPO="/etc/yum.repos.d/yarn.repo"
# If yarn is not detected, install it.
if which yarn; then
echo "Skipping installation of yarn -- yarn already installed."
echo "yarn --version: `yarn --version`"
else
echo "which yarn: `which yarn`"
echo "Yarn is not installed and accessible."
echo "Installing yarn..."
if [ ! -f $YARN_REPO ]; then
sudo wget https://dl.yarnpkg.com/rpm/yarn.repo -O $YARN_REPO
# Confirm that it downloaded
file /etc/yum.repos.d/yarn.repo
fi
# If node is not detected, install it.
if [ `node --version` == "v$NODE_VERSION" ]; then
echo "Skipping installation of node -- node already installed."
echo "node --version: `node --version`"
else
echo "Installing Node $NODE_VERSION"
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash
source ~/.nvm/nvm.sh
nvm install $NODE_VERSION
fi
# install yarn
sudo yum install -y yarn
yarn --version
echo "... and finished installing yarn."
fi
@aschuermann-at-neusta
Copy link

the amazon linux i use (docker image amazon/aws-cli) does not have wget/curl.
i tried to install that using yum but i did output a promt. i tried to fore y to the prompt using --y as described in a yum documentation but it says it doesn't know that flag.
This is a horrible rabbit hole.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment