所以我在aws codepipeline上部署了一个React web应用程序,我只是在项目中添加了新的特性,并将它们推到github,这会触发一个构建。几秒钟后我收到一封电子邮件,说它失败了,我去那里检查,发现了一个没有太大意义的错误。
以下是日志:
[Container] 2022/10/19 18:17:58 Phase context status code: Message:
[Container] 2022/10/19 18:17:58 Entering phase PRE_BUILD
[Container] 2022/10/19 18:17:58 Running command npm install
npm WARN saveError ENOENT: no such file or directory, open '/codebuild/output/src890598757/src/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/codebuild/output/src890598757/src/package.json'
npm WARN src No description
npm WARN src No repository field.
npm WARN src No README data
npm WARN src No license field.
up to date in 0.683s
found 0 vulnerabilities
[Container] 2022/10/19 18:18:11 Running command npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.
See `npm help init` for definitive documentation on these fields
and exactly what they do.
Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.
Press ^C at any time to quit.
package name: (src)
[Container] 2022/10/19 18:18:12 Command did not exit successfully npm init exit status 1
[Container] 2022/10/19 18:18:12 Phase complete: PRE_BUILD State: FAILED
[Container] 2022/10/19 18:18:12 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: npm init. Reason: exit status 1
EDIT以下是我的YAML文件:
version: 1
applications:
- frontend:
phases:
preBuild:
commands:
- npm i
build:
commands:
- npm run build
artifacts:
baseDirectory: build
files:
- '**/*'
cache:
paths:
- node_modules/**/*
appRoot: client
现在,我已经反复检查了我的回购协议和分支,一切都和以前完全一样,我确实有package.json和package-lock.json,所以这没有多大意义。
我参考了https://docs.aws.amazon.com/codebuild/latest/userguide/troubleshooting.html,试图找到一个解决方案,但人手不足,而Issue compiling with AWS Codebuild (vue.js project)是另一个问题,得到了一个代码构建错误,然而,我无法得出任何结论。
我敢肯定这是一个愚蠢的错误,所以我想知道是否有任何方法,我可以得到更多的信息,我的日志,并能够解决这个问题和进一步的错误,我会得到。
1条答案
按热度按时间7gs2gvoe1#
额外的日志记录将由您决定,向CodeBuild脚本正在运行的命令添加一些额外的日志记录级别。CodeBuild不能神奇地使
npm
命令吐出额外的日志记录,这将由您决定添加必要的标志或环境变量,以指示npm
吐出更多的日志。在这种情况下,我认为不需要额外的日志记录。错误是显而易见的。您已经向CodeBuild脚本添加了一个
npm init
命令,而该命令正在等待用户交互以输入一些值。您没有正确配置npm
命令,使其在非交互环境中运行。