【发布时间】:2021-02-08 22:49:39
【问题描述】:
我的 Codepipeline 非常适合
- 从 Github 拉取源文件
- 在 Codebuild 上构建一个正常工作的 Next.js 网站并输出到 S3
- 根据Codedeploy,部署S3文件Elastic Beanstalk时有成功
但是,一旦 Elastic Beanstalk 尝试运行,我就会遇到问题。
Oct 26 15:55:23 ip-xxx-xx-xx-xxx web: code: 'MODULE_NOT_FOUND',
Oct 26 15:55:23 ip-xxx-xx-xx-xxx web: requireStack: [ '/var/app/current/node_modules/.bin/next' ]
Oct 26 15:55:23 ip-xxx-xx-xx-xxx web: }
Oct 26 15:55:23 ip-xxx-xx-xx-xxx web: npm ERR! code ELIFECYCLE
Oct 26 15:55:23 ip-xxx-xx-xx-xxx web: npm ERR! errno 1
Oct 26 15:55:23 ip-xxx-xx-xx-xxx web: npm ERR! with-typescript@1.0.0 start: `next start`
Oct 26 15:55:23 ip-xxx-xx-xx-xxx web: npm ERR! Exit status 1
我的启动命令是next start,但似乎节点模块不存在。当我在 S3 中解压缩输出时,我看到了完整的 next.js 构建,所以这部分看起来还不错。我似乎无法找到为什么它不能在 ELB 上运行的解决方案——知道哪里出了问题吗?下面是我的buildspec.yml,供参考。
version: 0.2
phases:
install:
#If you use the Ubuntu standard image 2.0 or later, you must specify runtime-versions.
#If you specify runtime-versions and use an image other than Ubuntu standard image 2.0, the build fails.
runtime-versions:
nodejs: 12
commands:
- yarn
build:
commands:
- npx next build
artifacts:
files:
- '**/*'
更新
事实证明,一切就绪,但无法识别“下一个”命令。解决方案是在我的启动命令中使用绝对路径:node_modules/next/dist/bin/next start。
【问题讨论】:
标签: node.js amazon-elastic-beanstalk next.js aws-codepipeline aws-codebuild