我是一个新手,这个问题让我很困惑。
- 首先,我创建了一个应用程序,并使用他们的样本应用程序(节点v16)
- 我下载
eb cli
我使用 - 我创建了一个文件
.ebignore
,行/node_modules
- 我运行
npm run build
,然后测试它是否与npm run start
一起工作 - 我运行
eb init
并选择我的eb示例应用程序,然后我运行eb deploy
npx create-next-app@latest --typescript
创建了一个nextjs应用程序在第一次部署时,一切正常,我的应用程序被部署。
然而,我然后做一个小的文本更改运行npm run build
,然后eb deploy
在第二次尝试时,我得到错误:
2022-12-30 15:25:21 INFO Environment update is starting.
2022-12-30 15:25:26 INFO Deploying new version to instance(s).
2022-12-30 15:25:29 INFO 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.
2022-12-30 15:25:46 ERROR Instance deployment: 'npm' failed to install dependencies that you defined in 'package.json'. For details, see 'eb-engine.log'. The deployment failed.
2022-12-30 15:25:46 ERROR Instance deployment failed. For details, see 'eb-engine.log'.
2022-12-30 15:25:49 ERROR [Instance: i-08b3d32eff44fb29b] Command failed on instance. Return code: 1 Output: Engine
execution has encountered an error..
2022-12-30 15:25:49 INFO Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
2022-12-30 15:25:49 ERROR Unsuccessful command execution on instance id(s) 'i-08b3d32eff44fb29b'. Aborting the operation.
2022-12-30 15:25:49 ERROR Failed to deploy application.
当我请求eb-engine.log
的日志时,我得到:
2022/12/30 15:25:30.600993 [INFO] Running command /bin/sh -c npm --production install
2022/12/30 15:25:46.171460 [INFO] npm WARN config production Use `--omit=dev` instead.
npm ERR! code ENOMEM
npm ERR! syscall spawn
npm ERR! errno -12
npm ERR! spawn ENOMEM
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-12-30T15_25_30_951Z-debug-0.log
2022/12/30 15:25:46.171859 [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:npm WARN config production Use `--omit=dev` instead.
npm ERR! code ENOMEM
npm ERR! syscall spawn
npm ERR! errno -12
npm ERR! spawn ENOMEM
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-12-30T15_25_30_951Z-debug-0.log
2022/12/30 15:25:46.171867 [INFO] Executing cleanup logic
2022/12/30 15:25:46.171975 [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":1672413929779,"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":1672413946171,"severity":"ERROR"},{"msg":"Instance deployment failed. For details, see 'eb-engine.log'.","timestamp":1672413946171,"severity":"ERROR"}]}]}
2022/12/30 15:25:46.174080 [INFO] Platform Engine finished execution on command: app-deploy
[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:npm WARN config production Use `--omit=dev` instead.
不知道为什么它第一次部署它,但随后在我的其他尝试中出现错误。
问题是Elastic Beanstalk在运行npm install
时内存不足。
将配置更改为t2.large
,运行eb deploy
,然后将配置更改回t2.micro
&t2.small
修复了这个问题。