Strapi 版本 - 4.4.7 节点版本 - 16.13.1 AWS EB 平台 - 在 64 位 Amazon Linux 2/5.7.0 上运行的 Node.js 16 NODE_ENV - 生产
在本地一切正常,但在使用 AWS CodePipeline 将代码部署到 ElasticBeanstalk 实例后 - 项目无法启动。
Amazon Linux 2/5.6.4 - 工作正常 迁移到 Amazon Linux 2/5.7.0 后 - 不工作
.buildspec.yml 内容
version: 0.2
phases:
install:
runtime-versions:
nodejs: 16
commands:
- echo node -v
- node -v
- echo update npm...
- npm install -g n -f
- n 16.13.1
- npm update -g npm
- echo node -v
- node -v
- echo npm -v
- npm -v
- echo install yarn...
- npm install -g yarn
- echo yarn -v
- yarn -v
- echo Adding docker...
- nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay2&
- timeout 60 sh -c "until docker info; do echo .; sleep 3; done"
pre_build:
commands:
- echo Installing dependencies...
- yarn
build:
commands:
- echo Building...
- yarn build
post_build:
commands:
- echo Build completed on `date`
artifacts:
files:
- "Procfile"
- "package.json"
- "yarn.lock"
- "node_modules/**/*"
- "build/**/*"
- "src/**/*"
- "database/**/*"
- "config/**/*"
- "data/**/*"
- "public/**/*"
- "favicon.ico"
- ".platform/**/*"
- ".ebextensions/**/*"
运行 yarn start 后报错:
Mar 12 08:55:08 ip-172-31-26-92 web: Require stack:
Mar 12 08:55:08 ip-172-31-26-92 web: - /var/app/current/node_modules/.bin/strapi
Mar 12 08:55:08 ip-172-31-26-92 web: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1021:15)
Mar 12 08:55:08 ip-172-31-26-92 web: at Function.Module._load (node:internal/modules/cjs/loader:866:27)
Mar 12 08:55:08 ip-172-31-26-92 web: at Module.require (node:internal/modules/cjs/loader:1093:19)
Mar 12 08:55:08 ip-172-31-26-92 web: at require (node:internal/modules/cjs/helpers:108:18)
Mar 12 08:55:08 ip-172-31-26-92 web: at Object.<anonymous> (/var/app/current/node_modules/.bin/strapi:14:21)
Mar 12 08:55:08 ip-172-31-26-92 web: at Module._compile (node:internal/modules/cjs/loader:1191:14)
Mar 12 08:55:08 ip-172-31-26-92 web: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1245:10)
Mar 12 08:55:08 ip-172-31-26-92 web: at Module.load (node:internal/modules/cjs/loader:1069:32)
Mar 12 08:55:08 ip-172-31-26-92 web: at Function.Module._load (node:internal/modules/cjs/loader:904:12)
Mar 12 08:55:08 ip-172-31-26-92 web: at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
Mar 12 08:55:08 ip-172-31-26-92 web: code: 'MODULE_NOT_FOUND',
Mar 12 08:55:08 ip-172-31-26-92 web: requireStack: [ '/var/app/current/node_modules/.bin/strapi' ]
Mar 12 08:55:08 ip-172-31-26-92 web: }