为什么 npm install 只在 ElasticBeanstalk 中失败?
Why npm install failed only in ElasticBeanstalk?
我有一个 Nest.js (Node.js) 应用程序,我想将它部署在 ElasticBeanstalk(Node 16 版本,AL2 5.5.0)上。
我的部署一直失败,我在 eb-engine.log
.
中发现了错误
...
2022/03/23 15:11:48.570759 [INFO] Executing instruction: StageApplication
2022/03/23 15:11:48.570846 [INFO] extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/
2022/03/23 15:11:48.570860 [INFO] Running command /bin/sh -c /usr/bin/unzip -q -o /opt/elasticbeanstalk/deployment/app_source_bundle -d /var/app/staging/
2022/03/23 15:11:49.274806 [INFO] finished extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/ successfully
2022/03/23 15:11:49.289272 [INFO] Executing instruction: RunAppDeployPreBuildHooks
2022/03/23 15:11:49.289292 [INFO] Executing platform hooks in .platform/hooks/prebuild/
2022/03/23 15:11:49.289306 [INFO] The dir .platform/hooks/prebuild/ does not exist
2022/03/23 15:11:49.289311 [INFO] Executing instruction: Install customer specified node.js version
2022/03/23 15:11:49.289314 [INFO] installing specified nodejs version...
2022/03/23 15:11:49.289467 [INFO] there is no nodejs version specified in package.json, skip installing specified version of nodejs
2022/03/23 15:11:49.289476 [INFO] Executing instruction: Use NPM to install dependencies
2022/03/23 15:11:49.289484 [INFO] use npm to install dependencies
2022/03/23 15:11:49.289505 [INFO] Running command /bin/sh -c npm config set jobs 1
2022/03/23 15:11:49.574486 [INFO] Running command /bin/sh -c npm --production install
2022/03/23 15:12:06.913580 [ERROR] An error occurred during execution of command [app-deploy] - [Use NPM to install dependencies]. Stop running the command. Error: Command /bin/sh -c npm --production install failed with error signal: killed
...
我认为在生产模式下安装 npm 包时会出现错误,但我真的很想知道为什么会这样。我在我的本地计算机上执行了 npm --production install
,使用完全相同版本的节点和 npm 安装成功。 (节点 16.14.0,npm 8.3.1 - 目前最新的 AL2 5.5.0)。
我想知道为什么会出现这种情况以及如何调试更多细节(为什么在elastic beanstalk环境中npm install失败)。
我遇到了同样的问题,我能找到的唯一解决方法是增加实例 运行 应用程序的大小。为了让它工作,我不得不使用 t2.medium
.
您也可以尝试增加 EC2 实例 运行 您的应用程序的交换,但根据我的经验,这会使部署过程花费太长时间,有时甚至会失败。 (如果您想尝试这种方法,请参阅 )
我有一个 Nest.js (Node.js) 应用程序,我想将它部署在 ElasticBeanstalk(Node 16 版本,AL2 5.5.0)上。
我的部署一直失败,我在 eb-engine.log
.
...
2022/03/23 15:11:48.570759 [INFO] Executing instruction: StageApplication
2022/03/23 15:11:48.570846 [INFO] extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/
2022/03/23 15:11:48.570860 [INFO] Running command /bin/sh -c /usr/bin/unzip -q -o /opt/elasticbeanstalk/deployment/app_source_bundle -d /var/app/staging/
2022/03/23 15:11:49.274806 [INFO] finished extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/ successfully
2022/03/23 15:11:49.289272 [INFO] Executing instruction: RunAppDeployPreBuildHooks
2022/03/23 15:11:49.289292 [INFO] Executing platform hooks in .platform/hooks/prebuild/
2022/03/23 15:11:49.289306 [INFO] The dir .platform/hooks/prebuild/ does not exist
2022/03/23 15:11:49.289311 [INFO] Executing instruction: Install customer specified node.js version
2022/03/23 15:11:49.289314 [INFO] installing specified nodejs version...
2022/03/23 15:11:49.289467 [INFO] there is no nodejs version specified in package.json, skip installing specified version of nodejs
2022/03/23 15:11:49.289476 [INFO] Executing instruction: Use NPM to install dependencies
2022/03/23 15:11:49.289484 [INFO] use npm to install dependencies
2022/03/23 15:11:49.289505 [INFO] Running command /bin/sh -c npm config set jobs 1
2022/03/23 15:11:49.574486 [INFO] Running command /bin/sh -c npm --production install
2022/03/23 15:12:06.913580 [ERROR] An error occurred during execution of command [app-deploy] - [Use NPM to install dependencies]. Stop running the command. Error: Command /bin/sh -c npm --production install failed with error signal: killed
...
我认为在生产模式下安装 npm 包时会出现错误,但我真的很想知道为什么会这样。我在我的本地计算机上执行了 npm --production install
,使用完全相同版本的节点和 npm 安装成功。 (节点 16.14.0,npm 8.3.1 - 目前最新的 AL2 5.5.0)。
我想知道为什么会出现这种情况以及如何调试更多细节(为什么在elastic beanstalk环境中npm install失败)。
我遇到了同样的问题,我能找到的唯一解决方法是增加实例 运行 应用程序的大小。为了让它工作,我不得不使用 t2.medium
.
您也可以尝试增加 EC2 实例 运行 您的应用程序的交换,但根据我的经验,这会使部署过程花费太长时间,有时甚至会失败。 (如果您想尝试这种方法,请参阅