AWS Amplify React应用程序部署错误-重定向或AWS构建设置过多



首次在连接到Github repo的AWS Amplify上部署React应用程序。应用程序在本地运行,并且似乎在AWS上成功构建。当我在Chrome中启动应用程序时,我收到一个错误页面:ERR_TOO_MANY_REDDIRECTS。我看到的唯一潜在问题是在AWS构建过程中,当我进入构建设置时,我会收到两个警告

version: 0.1
frontend:
phases:
# IMPORTANT - Please verify your build commands
build:
commands: []
artifacts:
# IMPORTANT - Please verify your build output directory
baseDirectory: /
files:
- '**/*'
cache:
paths: []

我找不到太多关于纠正这些问题的指导,或者这些问题是否存在。我的应用程序正在使用npm。不确定应用程序中的哪些代码对发布有用,我将提供回购链接。任何帮助或正确的方向调试这将是伟大的。https://github.com/travelerr/chatterfield

AWS的前端构建输出:

2020-05-11T11:36:03.308Z [WARNING]: npm
2020-05-11T11:36:03.310Z [WARNING]: ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the client@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-05-11T11:36:03.318Z [WARNING]: 
2020-05-11T11:36:03.319Z [WARNING]: npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-05-11T11_36_03_312Z-debug.log
2020-05-11T11:36:03.319Z [HELP]: Outputting the npm debug log
0 info it worked if it ends with ok
1 verbose cli [ '/root/.nvm/versions/node/v10.16.0/bin/node',
1 verbose cli   '/root/.nvm/versions/node/v10.16.0/bin/npm',
1 verbose cli   'run',
1 verbose cli   'build' ]
2 info using npm@6.9.0
3 info using node@v10.16.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle client@0.1.0~prebuild: client@0.1.0
6 info lifecycle client@0.1.0~build: client@0.1.0
7 verbose lifecycle client@0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle client@0.1.0~build: PATH: /root/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/codebuild/output/src742497908/src/chatterfield/client/node_modules/.bin:/usr/local/rvm/gems/ruby-2.4.6/bin:/usr/local/rvm/gems/ruby-2.4.6@global/bin:/usr/local/rvm/rubies/ruby-2.4.6/bin:/usr/local/rvm/bin:/root/.yarn/bin:/root/.config/yarn/global/node_modules/.bin:/root/.nvm/versions/node/v10.16.0/bin:/root/.local/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
9 verbose lifecycle client@0.1.0~build: CWD: /codebuild/output/src742497908/src/chatterfield/client
10 silly lifecycle client@0.1.0~build: Args: [ '-c', 'react-scripts build' ]
11 silly lifecycle client@0.1.0~build: Returned: code: 1  signal: null
12 info lifecycle client@0.1.0~build: Failed to exec build script
13 verbose stack Error: client@0.1.0 build: `react-scripts build`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/root/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:198:13)
13 verbose stack     at ChildProcess.<anonymous> (/root/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:198:13)
13 verbose stack     at maybeClose (internal/child_process.js:982:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid client@0.1.0
15 verbose cwd /codebuild/output/src742497908/src/chatterfield/client
16 verbose Linux 4.14.173-106.229.amzn1.x86_64
17 verbose argv "/root/.nvm/versions/node/v10.16.0/bin/node" "/root/.nvm/versions/node/v10.16.0/bin/npm" "run" "build"
18 verbose node v10.16.0
19 verbose npm  v6.9.0
20 error code ELIFECYCLE
21 error errno 1
22 error client@0.1.0 build: `react-scripts build`
22 error Exit status 1
23 error Failed at the client@0.1.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

当我意识到这些构建设置没有多大作用时,我也遇到了同样的问题。您需要配置React应用程序的正确目录,安装所需的npm包并构建您的应用程序。最后,您需要将构建目录的完整路径配置为"baseDirectory"。

在你的情况下,我认为合适的构建设置是:

version: 0.1
frontend:
phases:
preBuild:
commands:
- cd client
- npm install
build:
commands: 
- npm run build
artifacts:
baseDirectory: /client/build
files:
- '**/*'
cache:
paths: []

一个可能对您有所帮助的有用链接:配置构建设置

最新更新