gpt4 book ai didi

npm - 构建成功运行 `next build` 时,AWS CodeBuild 不生成任何工件

转载 作者:行者123 更新时间:2023-12-05 06:56:46 26 4
gpt4 key购买 nike

我正在使用 NextJS 并尝试进行 CI 以构建和部署到 AWS Beanstalk。

这是我的buildspec.yml

version: 0.2
env:
variables:
NODE_ENV: "production"
phases:
pre_build:
commands:
- echo Installing dependencies
- npm install
build:
commands:
- echo Building nextjs app
- npm run build
post_build:
commands:
- echo Build completed on `date`
artifacts:
files:
- '**/*'

我正在监视日志并且没有错误,但是 Build 阶段没有生成任何工件。因此,一旦管道移动到部署阶段。我在日志中收到此错误:

----------------------------------------
/var/log/web.stdout.log
----------------------------------------
Nov 30 01:47:31 ip-172-31-50-67 web: at /var/app/current/node_modules/next/dist/bin/next:26:341
Nov 30 01:47:31 ip-172-31-50-67 web: npm ERR! code ELIFECYCLE
Nov 30 01:47:31 ip-172-31-50-67 web: npm ERR! errno 1
Nov 30 01:47:31 ip-172-31-50-67 web: npm ERR! with-typescript@1.0.0 start: `next start`
Nov 30 01:47:31 ip-172-31-50-67 web: npm ERR! Exit status 1
Nov 30 01:47:31 ip-172-31-50-67 web: npm ERR!
Nov 30 01:47:31 ip-172-31-50-67 web: npm ERR! Failed at the with-typescript@1.0.0 start script.
Nov 30 01:47:31 ip-172-31-50-67 web: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Nov 30 01:47:31 ip-172-31-50-67 web: npm ERR! A complete log of this run can be found in:
Nov 30 01:47:31 ip-172-31-50-67 web: npm ERR! /home/webapp/.npm/_logs/2020-11-30T01_47_31_607Z-debug.log
Nov 30 01:47:32 ip-172-31-50-67 web: > with-typescript@1.0.0 start /var/app/current
Nov 30 01:47:32 ip-172-31-50-67 web: > next start
Nov 30 01:47:32 ip-172-31-50-67 web: Error: Could not find a valid build in the '/var/app/current/.next' directory! Try building your app with 'next build' before starting the server.
Nov 30 01:47:32 ip-172-31-50-67 web: at Server.readBuildId (/var/app/current/node_modules/next/dist/next-server/server/next-server.js:137:355)
Nov 30 01:47:32 ip-172-31-50-67 web: at new Server (/var/app/current/node_modules/next/dist/next-server/server/next-server.js:3:120)
Nov 30 01:47:32 ip-172-31-50-67 web: at createServer (/var/app/current/node_modules/next/dist/server/next.js:2:638)
Nov 30 01:47:32 ip-172-31-50-67 web: at start (/var/app/current/node_modules/next/dist/server/lib/start-server.js:1:323)
Nov 30 01:47:32 ip-172-31-50-67 web: at nextStart (/var/app/current/node_modules/next/dist/cli/next-start.js:19:125)

我不明白我还能做什么?我试过将 Build 阶段的 Artifacts 设置更改为加密和未加密,我试过无缓存本地,以及带有缓存桶的 Amazon S3。这些似乎都不会产生任何人工制品。

谁能指出我做错了什么?

最佳答案

基于评论。

此问题是由于构建操作之后的部署操作中 Input Artifact 设置不正确造成的。 Input Artifact 应设置为 buildartifacts,它是构建操作的输出工件。

关于npm - 构建成功运行 `next build` 时,AWS CodeBuild 不生成任何工件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65067328/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com