Kevin. Kevin. - 4 months ago 17
Node.js Question

Node.js deployment issue on Amazon Elastic Beanstalk

I'm trying to deploy a node.js app using the Amazon Elastic Beanstalk service. Following this tutorial (http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs.sdlc.html), I managed to deploy the app. However, once uploaded on Amazon, the application failed to start. Investigating the logs show me the following error : "Failed to run npm install".

Does anyone have a good idea of what the problem might be ? The application is working great locally.

Thanks in advance for your help!

Answer

I was having the same issue and Kevin's solution solved the problem for me, but introduced another: New instances spawned by EB for auto-scaling also need the manual configuration. This is the modification to Kevin's method that I made to solve both issues:

Another way to solve Kevin's issue is to add the required packages to a config file for your application. Create a configuration file with the extension .config (e.g., myapp.config) and place it in an .ebextensions top-level directory of your source bundle. In order to require the openssl-devel package, include these lines in the config file:

packages:
    yum:
        openssl-devel: []

For details on where the config file goes: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs_custom_container.html

And details on including packages (and more) in the config file: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html

Comments