Ruby on Rails 6 now relies on webpack to deal with asset compilation so you will absolutely need to have node and yarn installed on the deployment instances. Here's how it can be accomplished. It's actually pretty straight-forward to setup.


  • Any Amazon Linux 2 based AMI (Amazon Linux 1 has a different way of doing this)

I tested this with Ruby 2.7 running on 64bit Amazon Linux 2/3.1.2 but one can presume it would work with other stacks as well.

First, you need two new files in your application directory under the special .ebextensions directory at the root:


The order of which these are executed can be important which is why they are prefixed with two digits. You can check the official AWS documentation on how these config YAML files work.


This will install node using the recommended method for Red Hat Enterprise Linux (Amazon Linux 2 is a flavor of RHEL) and yarn via bash scripts & commands.

    test: '[ ! -f /usr/bin/node ] && echo "node not installed"'
    cwd: /tmp
    command: curl --silent --location | sudo bash -
    test: '[ ! -f /etc/yum.repos.d/yarn.repo ] && echo "yarn repo not installed"'
    cwd: /tmp
    command: curl --silent --location | sudo tee /etc/yum.repos.d/yarn.repo
    test: '[ ! -f /usr/bin/yarn ] && echo "yarn not installed"'
    command: rpm -Uvh --nodeps $(repoquery --location yarn)

Yarn was the tricky part to figure out. The recommended way is via a provided bash script but that script installs yarn into the current user's home directory (and that would be root!). We need it available globally (say in /bin/yarn or /usr/bin/yarn) and accessible to a non-root user. Using the yum package manager would definitely be the way to go... But of course if you tried it would complain that it has a dependency on nodejs and it's not installed or available. We installed node using a custom script and not via yum. Turns out though that we can ignore the dependency if we use the rpm command to install yarn (yum install yarn --skip-broken will not work). For some reason the maintainers of NodeJS opted out of using yum for RHEL and this is what we need to contend with.


This will install git as you may need it if you have git repositories in your Gemfile. Feel free to add any other dependencies you may need. (The empty array means 'install the latest version'.)

    git: []
    yarn: []

Now deploy your application and both yarn and node should be available. If there are any issues, you most likely will see them in the /var/log/eb-engine.log log and in /var/log/cfn-init.log.