I have a Nest.js (Node.js) application, and I want to deploy it on ElasticBeanstalk (Node 16 version, AL2 5.5.0).
My deployment keeps failing, and I found the error in 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
...
I think the error occurs when installing npm packages in production mode, but I'm really wondering why this happens. I executed npm --production install
in my local computer, the installing was successful with the exactly same versions of node & npm. (Node 16.14.0, npm 8.3.1 - AL2 5.5.0 latest for now).
I want to know why this happens and how to debug more details (why npm install failed in the elastic beanstalk environment).