简体   繁体   English

Amazon Elastic Beanstalk上的Node.js部署问题

[英]Node.js deployment issue on Amazon Elastic Beanstalk

I'm trying to deploy a node.js app using the Amazon Elastic Beanstalk service. 我正在尝试使用Amazon Elastic Beanstalk服务部署node.js应用程序。 Following this tutorial ( http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs.sdlc.html ), I managed to deploy the app. 按照本教程( http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs.sdlc.html ),我设法部署了应用程序。 However, once uploaded on Amazon, the application failed to start. 但是,一旦在亚马逊上传,该应用程序就无法启动。 Investigating the logs show me the following error : "Failed to run npm install". 调查日志显示以下错误:“无法运行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! 在此先感谢您的帮助!

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. 我遇到了同样的问题,Kevin的解决方案为我解决了问题,但又引入了另一个问题:EB为自动扩展生成的新实例也需要手动配置。 This is the modification to Kevin's method that I made to solve both issues: 这是我用来解决这两个问题的Kevin方法的修改:

Another way to solve Kevin's issue is to add the required packages to a config file for your application. 解决Kevin问题的另一种方法是将所需的包添加到应用程序的配置文件中。 Create a configuration file with the extension .config (eg, myapp.config) and place it in an .ebextensions top-level directory of your source bundle. 创建扩展名为.config的配置文件(例如,myapp.config),并将其放在源包的.ebextensions顶级目录中。 In order to require the openssl-devel package, include these lines in the config file: 为了要求openssl-devel包,请在配置文件中包含以下行:

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 有关配置文件的位置的详细信息: 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 有关在配置文件中包含软件包(以及更多)的详细信息: http//docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html

I found out what the problem was. 我发现了问题所在。 Here is the explanation. 这是解释。

The reason why the npm package manager failed to install some packages was due to the fact that some packages required linux libraries to be install first (ie, OpenSSL-devel). npm包管理器无法安装某些包的原因是因为某些包需要首先安装linux库(即OpenSSL-devel)。 In order to resolve this problem, I had to : 为了解决这个问题,我不得不:

1. SSH to my EC2 instance associated with my Node.js Elastic Beanstalk instance 1. SSH到我的Node.js Elastic Beanstalk实例关联的EC2实例

First, remove the "Termination Protection" on your EC2 instance (Click on your EC2 instance then look for "Change Termination Protection". Then, you need to add a "KeyPair" to the EC2 instance. For that, go to the ELB manager and edit the configuration file of your ELB application. For detailed explainations, check this link ( SSH to Elastic Beanstalk instance ) 首先,删除EC2实例上的“终止保护”(单击您的EC2实例,然后查找“更改终止保护”。然后,您需要向EC2实例添加“KeyPair”。为此,请转到ELB管理器并编辑ELB应用程序的配置文件。有关详细说明,请查看此链接( SSH到Elastic Beanstalk实例

2. Install the missing libraries (in my case, because the bcrypt npm package was requiring it) 2.安装缺少的库 (在我的情况下,因为bcrypt npm包需要它)

sudo yum update

sudo yum install openssl-devel

Hope this helps! 希望这可以帮助!

我遇到了这个问题,并通过简单地选择下一个更大的实例类型来解决它。

我发现了一个类似的问题,对我来说错误是因为一个节点包没有成功安装,所以当我从package.json中删除该节点包因为我真的不需要它,它工作了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM