Quick tips on deploying Node.js apps to Elastic Beanstalk
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.
