AWS Amplify React App部署错误-重定向或AWS Build设置过多

时间:2020-05-09 00:50:31

标签: reactjs amazon-web-services debugging deployment aws-amplify

首次在连接到Github存储库的AWS Amplify上部署React应用程序。应用程序在本地运行,并且似乎可以在AWS上成功构建。当我在Chrome中启动应用程序时,收到错误页面:ERR_TOO_MANY_REDIRECTS。我看到的唯一潜在问题是在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 ]

1 个答案:

答案 0 :(得分:2)

当我意识到这些构建设置的作用不大时,我遇到了同样的问题。您需要配置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: []

一个有用的链接可能会帮助您:Configuring Build Settings