Currently you can't install yarn using yum so there doesn't seem to be an easy way to create a config that installs it before asset pre-compilation.
Asked
Active
Viewed 6,361 times
2 Answers
11
You can customize packages that are installed and commands that are run on deploy with .ebextensions
For yarn, I created a file with the following commands which install a recent node version and yarn:
# .ebextensions/yarn.config
commands:
01_install_node:
command: |
sudo curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
sudo yum -y install nodejs
02_install_yarn:
# don't run the command if yarn is already installed (file /usr/bin/yarn exists)
test: '[ ! -f /usr/bin/yarn ] && echo "Yarn not found, installing..."'
command: |
sudo wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo
sudo yum -y install yarn
More Documentation: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html

Jared Moody
- 296
- 1
- 4
- 10
-
1thanks for that script. I've just fixed a missing single quote at the end of `test` line – fagiani Aug 19 '18 at 12:58
-
See my answer if one would prefer use the `node` provided by platform to install the `yarn`: https://serverfault.com/a/1051810/304519 – Yuki Inoue Jan 31 '21 at 07:24
3
As stated in the accepted answer, you can create .ebextensions/some.config
to order EB instances to install yarn on the instance creation. In current EB environment, I find following config to be more succinct and understandable:
# .ebextensions/some.config
commands:
01_install_yarn:
command: |
set -e
npm i -g yarn
ln -s "$(npm bin --global)"/yarn /usr/bin/yarn
test: "! yarn -v"
In fact, current EB ruby environment includes node
binary available at /usr/bin/node
, you can use that to install yarn
via npm
.

Yuki Inoue
- 231
- 2
- 6