【问题标题】:AWS Elastic Beanstalk NPM error on deploymentAWS Elastic Beanstalk NPM 部署错误
【发布时间】:2021-08-28 14:25:08
【问题描述】:

我在 AWS EC2 实例上运行我的前端并使用代码管道将我的代码交付到部署。执行时出现此错误,并且我当前的构建无法执行超出此点。但在我的本地主机中,一切正常。

这是来自我的/var/log/eb-engine.log的错误

2021/06/11 15:54:30.130038 [INFO] Running command /bin/sh -c npm config set jobs 1
2021/06/11 15:54:30.726850 [INFO] Running command /bin/sh -c npm --production install
2021/06/11 15:55:25.517929 [INFO] 
> ejs@2.7.4 postinstall /var/app/staging/node_modules/@surma/rollup-plugin-off-main-thread/node_modules/ejs
> node ./postinstall.js


2021/06/11 15:55:25.520296 [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 exit status 244. Stderr:
 

2021/06/11 15:55:25.520730 [INFO] Executing cleanup logic
2021/06/11 15:55:25.529146 [INFO] CommandService Response: {"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"Engine execution has encountered an error.","returncode":1,"events":[{"msg":"Instance deployment: You didn't specify a Node.js version in the 'package.json' file in your source bundle. The deployment didn't install a specific Node.js version.","timestamp":1623426870,"severity":"INFO"},{"msg":"Instance deployment: 'npm' failed to install dependencies that you defined in 'package.json'. For details, see 'eb-engine.log'. The deployment failed.","timestamp":1623426925,"severity":"ERROR"},{"msg":"Instance deployment failed. For details, see 'eb-engine.log'.","timestamp":1623426925,"severity":"ERROR"}]}]}

2021/06/11 15:55:25.535409 [INFO] Platform Engine finished execution on command: app-deploy

我在 EC2 上使用 t2.micro 实例。

【问题讨论】:

  • 部署文件中发生了什么(即在 npm install --production 之前)?

标签: node.js amazon-web-services npm amazon-elastic-beanstalk ejs


【解决方案1】:

这看起来像是 AWS 实例中的 npm install 命令的问题。 使用 npm install --only=prod(或 --only=production)。如果 npm 版本大于 v3.3.0

在 npm (2015-08-13) v3.3.0 之前,该选项被称为 --production,即 npm install --production。

【讨论】:

  • 我已经尝试过这个并添加了一个 Procfile 来运行一个执行 npm install --only=prod 的部署脚本,但我尝试部署 8/10 次仍然遇到相同的错误。
猜你喜欢
  • 2019-02-22
  • 2017-10-04
  • 2014-12-16
  • 2020-04-25
  • 2017-12-09
  • 2015-09-20
  • 1970-01-01
  • 2020-08-02
  • 2014-12-25
相关资源
最近更新 更多