Quick tips on deploying Node.js apps to Elastic Beanstalk

Dominic Wong
Aug 22, 2017 · 1 min read

Tip 1: Do not use yum to install node and npm. It will give you a very old version. Instead, select a platform that runs Node.js and create symlinks in a config file in .ebextensions (Surprisingly you will get command not found when you try to run node and npm).

commands:
01_ln_node:
command: 'ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/node /bin/node'
02_ln_npm:
command: 'ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/npm /bin/npm'

This config file grabs the latest installed node version in the instance and creates symlinks for node and npm.

Tip 2: If nothing works, run the build locally.

You will likely run into many issues when you run npm install and npm run build when you deploy the app. If nothing works, commit the dist directory to the repository. Obviously this is not the best solution, but it works.

)

Written by

Writing bad articles until my articles become awesome.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade