简体   繁体   English

AWS Amplify React App Deploy 错误 - 重定向或 AWS 构建设置过多

[英]AWS Amplify React App Deploy Error- Too many redirect or AWS Build Settings

First time deploying a React application on AWS Amplify connected to Github repo.第一次在连接到 Github 存储库的 AWS Amplify 上部署 React 应用程序。 App works locally and seems to build successfully on AWS.应用程序在本地工作,并且似乎在 AWS 上成功构建。 When I launch app in Chrome I receive an error page: ERR_TOO_MANY_REDIRECTS.当我在 Chrome 中启动应用程序时,我收到一个错误页面:ERR_TOO_MANY_REDIRECTS。 The only potential issue I see is during the AWS build is when I get to build setting I get two warnings我看到的唯一潜在问题是在 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: []

I cannot find much guidance on correcting these, or if these are even the problem.我找不到太多关于纠正这些问题的指导,或者这些甚至是问题所在。 Im using npm for my application.我在我的应用程序中使用 npm。 Not sure what code from app would be useful to post, I will provide repo link.不确定应用程序中的哪些代码对发布有用,我将提供 repo 链接。 Any help or a point in the right direction to debug this would be great.任何帮助或正确的调试方向都会很棒。 https://github.com/travelerr/chatterfield https://github.com/travelerr/chatterfield

Frontend Build Output from AWS: AWS 的前端构建 Output:

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 ]

I had the same issue, when I realized that these build settings are not doing much.当我意识到这些构建设置并没有多大作用时,我遇到了同样的问题。 You need to configure the proper directory of the React app, install the needed npm packages and build your application.您需要配置 React 应用程序的正确目录,安装所需的 npm 包并构建您的应用程序。 In the end, you need to configure the full path to your build directory as 'baseDirectory'.最后,您需要将构建目录的完整路径配置为“baseDirectory”。

In your case, I think the proper build settings would be:在您的情况下,我认为正确的构建设置是:

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

A useful link that might help you: Configuring Build Settings一个可能对您有所帮助的有用链接: 配置构建设置

I'm getting the same issue.我遇到了同样的问题。

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - npm ci
    build:
      commands:
        - npm run build
  artifacts:
    # IMPORTANT - Please verify your build output directory
    baseDirectory: /
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

2021-12-09T14:13:22.355Z [INFO]: Git SSH Key acquired
2021-12-09T14:13:22.430Z [INFO]: # Cloning repository: git@github.com:jmfcool/jmfcool.react.git
2021-12-09T14:13:22.514Z [INFO]: Agent pid 134
2021-12-09T14:13:22.547Z [INFO]: Identity added: /root/.ssh/git_rsa (/root/.ssh/git_rsa)
2021-12-09T14:13:22.810Z [INFO]: Cloning into 'jmfcool.react'...
2021-12-09T14:13:23.109Z [INFO]: Warning: Permanently added the ECDSA host key for IP address '140.82.114.3' to the list of known hosts.
2021-12-09T14:13:24.956Z [INFO]: # Switching to commit: 3ac7431ee4752f3fed5f9334dad90bfe1bf316f1
2021-12-09T14:13:25.132Z [INFO]: Agent pid 147
2021-12-09T14:13:25.132Z [INFO]: Identity added: /root/.ssh/git_rsa (/root/.ssh/git_rsa)
                                 Note: switching to '3ac7431ee4752f3fed5f9334dad90bfe1bf316f1'.
                                 You are in 'detached HEAD' state. You can look around, make experimental
                                 changes and commit them, and you can discard any commits you make in this
                                 state without impacting any branches by switching back to a branch.
                                 If you want to create a new branch to retain commits you create, you may
                                 do so (now or later) by using -c with the switch command. Example:
                                 git switch -c <new-branch-name>
                                 Or undo this operation with:
                                 git switch -
                                 Turn off this advice by setting config variable advice.detachedHead to false
                                 HEAD is now at 3ac7431 Update footer
2021-12-09T14:13:25.138Z [INFO]: Successfully cleaned up Git credentials
2021-12-09T14:13:25.138Z [INFO]: # Checking for Git submodules at: /codebuild/output/src242895337/src/jmfcool.react/.gitmodules
2021-12-09T14:13:25.159Z [INFO]: # Retrieving environment cache...
2021-12-09T14:13:25.224Z [INFO]: # Retrieved environment cache
2021-12-09T14:13:25.224Z [INFO]: ---- Setting Up SSM Secrets ----
2021-12-09T14:13:25.224Z [INFO]: SSM params {"Path":"/amplify/d3a41fccs4kkio/main/","WithDecryption":true}
2021-12-09T14:13:25.259Z [WARNING]: !Failed to set up process.env.secrets
2021-12-09T14:13:25.259Z [WARNING]: ! Unable to patch packages...
2021-12-09T14:13:25.267Z [INFO]: # Retrieving cache...
2021-12-09T14:13:30.180Z [INFO]: # Extracting cache...
2021-12-09T14:13:35.183Z [INFO]: # Extraction completed
2021-12-09T14:13:55.182Z [INFO]: ## Starting Backend Build
                                 ## Checking for associated backend environment...
                                 ## No backend environment association found, continuing...
                                 ## Completed Backend Build
                                 ## Starting Frontend Build
                                 # Starting phase: preBuild
                                 # Executing command: npm ci
2021-12-09T14:13:57.231Z [WARNING]: npm
2021-12-09T14:13:57.232Z [WARNING]: WARN
2021-12-09T14:13:57.232Z [WARNING]: prepare removing existing node_modules/ before installation
2021-12-09T14:14:11.442Z [INFO]: > core-js@2.6.12 postinstall /codebuild/output/src242895337/src/jmfcool.react/node_modules/babel-runtime/node_modules/core-js
                                 > node -e "try{require('./postinstall')}catch(e){}"
2021-12-09T14:14:11.486Z [INFO]: [96mThank you for using core-js ([94m https://github.com/zloirock/core-js [96m) for polyfilling JavaScript standard library![0m
                                 [96mThe project needs your help! Please consider supporting of core-js on Open Collective or Patreon: [0m
                                 [96m>[94m https://opencollective.com/core-js [0m
                                 [96m>[94m https://www.patreon.com/zloirock [0m
                                 [96mAlso, the author of core-js ([94m https://github.com/zloirock [96m) is looking for a good job -)[0m
2021-12-09T14:14:11.509Z [INFO]: > ejs@2.7.4 postinstall /codebuild/output/src242895337/src/jmfcool.react/node_modules/ejs
                                 > node ./postinstall.js
2021-12-09T14:14:11.548Z [INFO]: Thank you for installing [35mEJS[0m: built with the [32mJake[0m JavaScript build tool ([32mhttps://jakejs.com/[0m)
2021-12-09T14:14:11.714Z [INFO]: > fsevents@1.2.13 install /codebuild/output/src242895337/src/jmfcool.react/node_modules/webpack-dev-server/node_modules/fsevents
                                 > node install.js
2021-12-09T14:14:11.753Z [INFO]: 
2021-12-09T14:14:11.753Z [INFO]: Skipping 'fsevents' build as platform linux is not supported
2021-12-09T14:14:11.782Z [INFO]: > fsevents@1.2.13 install /codebuild/output/src242895337/src/jmfcool.react/node_modules/watchpack-chokidar2/node_modules/fsevents
                                 > node install.js
2021-12-09T14:14:11.820Z [INFO]: 
2021-12-09T14:14:11.820Z [INFO]: Skipping 'fsevents' build as platform linux is not supported
2021-12-09T14:14:11.968Z [INFO]: > core-js@3.18.3 postinstall /codebuild/output/src242895337/src/jmfcool.react/node_modules/core-js
                                 > node -e "try{require('./postinstall')}catch(e){}"
2021-12-09T14:14:12.010Z [INFO]: [96mThank you for using core-js ([94m https://github.com/zloirock/core-js [96m) for polyfilling JavaScript standard library![0m
                                 [96mThe project needs your help! Please consider supporting of core-js:[0m
                                 [96m>[94m https://opencollective.com/core-js [0m
                                 [96m>[94m https://patreon.com/zloirock [0m
                                 [96m>[94m https://paypal.me/zloirock [0m
                                 [96m>[94m bitcoin: bc1qlea7544qtsmj2rayg0lthvza9fau63ux0fstcz [0m
                                 [96mAlso, the author of core-js ([94m https://github.com/zloirock [96m) is looking for a good job -)[0m
2021-12-09T14:14:12.362Z [INFO]: > core-js-pure@3.18.3 postinstall /codebuild/output/src242895337/src/jmfcool.react/node_modules/core-js-pure
                                 > node -e "try{require('./postinstall')}catch(e){}"
2021-12-09T14:14:12.527Z [INFO]: > @fortawesome/fontawesome-common-types@0.2.36 postinstall /codebuild/output/src242895337/src/jmfcool.react/node_modules/@fortawesome/fontawesome-common-types
                                 > node attribution.js
2021-12-09T14:14:12.564Z [INFO]: Font Awesome Free 0.2.36 by @fontawesome - https://fontawesome.com
                                 License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
2021-12-09T14:14:12.568Z [INFO]: > @fortawesome/free-solid-svg-icons@5.15.4 postinstall /codebuild/output/src242895337/src/jmfcool.react/node_modules/@fortawesome/free-solid-svg-icons
                                 > node attribution.js
2021-12-09T14:14:12.605Z [INFO]: Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com
                                 License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
2021-12-09T14:14:12.609Z [INFO]: > @fortawesome/free-regular-svg-icons@5.15.4 postinstall /codebuild/output/src242895337/src/jmfcool.react/node_modules/@fortawesome/free-regular-svg-icons
                                 > node attribution.js
2021-12-09T14:14:12.645Z [INFO]: Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com
                                 License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
2021-12-09T14:14:12.649Z [INFO]: > @fortawesome/free-brands-svg-icons@5.15.4 postinstall /codebuild/output/src242895337/src/jmfcool.react/node_modules/@fortawesome/free-brands-svg-icons
                                 > node attribution.js
2021-12-09T14:14:12.685Z [INFO]: Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com
                                 License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
2021-12-09T14:14:12.690Z [INFO]: > @fortawesome/fontawesome-svg-core@1.2.36 postinstall /codebuild/output/src242895337/src/jmfcool.react/node_modules/@fortawesome/fontawesome-svg-core
                                 > node attribution.js
2021-12-09T14:14:12.728Z [INFO]: Font Awesome Free 1.2.36 by @fontawesome - https://fontawesome.com
                                 License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
2021-12-09T14:14:12.732Z [INFO]: added 2066 packages in 15.521s
2021-12-09T14:14:12.747Z [INFO]: # Completed phase: preBuild
                                 # Starting phase: build
2021-12-09T14:14:12.747Z [INFO]: # Executing command: npm run build
2021-12-09T14:14:12.909Z [INFO]: > jmfcool.react@0.1.0 build /codebuild/output/src242895337/src/jmfcool.react
                                 > react-scripts build
2021-12-09T14:14:14.013Z [INFO]: Creating an optimized production build...
2021-12-09T14:14:18.209Z [INFO]: Failed to compile.
2021-12-09T14:14:18.211Z [INFO]: ./src/Abouts.js
                                 Cannot find file './img/marketing.png' in './src'.
2021-12-09T14:14:18.224Z [WARNING]: npm
2021-12-09T14:14:18.224Z [WARNING]: ERR! code ELIFECYCLE
                                    npm ERR! errno 1
2021-12-09T14:14:18.226Z [WARNING]: npm
2021-12-09T14:14:18.227Z [WARNING]: ERR! jmfcool.react@0.1.0 build: `react-scripts build`
                                    npm ERR! Exit status 1
                                    npm ERR!
                                    npm ERR! Failed at the jmfcool.react@0.1.0 build script.
                                    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-12-09T14:14:18.231Z [WARNING]: 
2021-12-09T14:14:18.231Z [WARNING]: npm ERR! A complete log of this run can be found in:
                                    npm ERR!     /root/.npm/_logs/2021-12-09T14_14_18_227Z-debug.log
2021-12-09T14:14:18.231Z [HELP]: Outputting the npm debug log
                                 0 info it worked if it ends with ok
                                 1 verbose cli [
                                 1 verbose cli   '/root/.nvm/versions/node/v12.21.0/bin/node',
                                 1 verbose cli   '/root/.nvm/versions/node/v12.21.0/bin/npm',
                                 1 verbose cli   'run',
                                 1 verbose cli   'build'
                                 1 verbose cli ]
                                 2 info using npm@6.14.11
                                 3 info using node@v12.21.0
                                 4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
                                 5 info lifecycle jmfcool.react@0.1.0~prebuild: jmfcool.react@0.1.0
                                 6 info lifecycle jmfcool.react@0.1.0~build: jmfcool.react@0.1.0
                                 7 verbose lifecycle jmfcool.react@0.1.0~build: unsafe-perm in lifecycle true
                                 8 verbose lifecycle jmfcool.react@0.1.0~build: PATH: /root/.nvm/versions/node/v12.21.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/codebuild/output/src242895337/src/jmfcool.react/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/v12.21.0/bin:/root/.local/bin:/root/.local/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.dotnet/tools
                                 9 verbose lifecycle jmfcool.react@0.1.0~build: CWD: /codebuild/output/src242895337/src/jmfcool.react
                                 10 silly lifecycle jmfcool.react@0.1.0~build: Args: [ '-c', 'react-scripts build' ]
                                 11 silly lifecycle jmfcool.react@0.1.0~build: Returned: code: 1  signal: null
                                 12 info lifecycle jmfcool.react@0.1.0~build: Failed to exec build script
                                 13 verbose stack Error: jmfcool.react@0.1.0 build: `react-scripts build`
                                 13 verbose stack Exit status 1
                                 13 verbose stack     at EventEmitter.<anonymous> (/root/.nvm/versions/node/v12.21.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
                                 13 verbose stack     at EventEmitter.emit (events.js:314:20)
                                 13 verbose stack     at ChildProcess.<anonymous> (/root/.nvm/versions/node/v12.21.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
                                 13 verbose stack     at ChildProcess.emit (events.js:314:20)
                                 13 verbose stack     at maybeClose (internal/child_process.js:1022:16)
                                 13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
                                 14 verbose pkgid jmfcool.react@0.1.0
                                 15 verbose cwd /codebuild/output/src242895337/src/jmfcool.react
                                 16 verbose Linux 4.14.252-195.483.amzn2.x86_64
                                 17 verbose argv "/root/.nvm/versions/node/v12.21.0/bin/node" "/root/.nvm/versions/node/v12.21.0/bin/npm" "run" "build"
                                 18 verbose node v12.21.0
                                 19 verbose npm  v6.14.11
                                 20 error code ELIFECYCLE
                                 21 error errno 1
                                 22 error jmfcool.react@0.1.0 build: `react-scripts build`
                                 22 error Exit status 1
                                 23 error Failed at the jmfcool.react@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 ]
2021-12-09T14:14:18.234Z [ERROR]: !!! Build failed
2021-12-09T14:14:18.235Z [ERROR]: !!! Non-Zero Exit Code detected
2021-12-09T14:14:18.235Z [INFO]: # Starting environment caching...
2021-12-09T14:14:18.235Z [INFO]: # Uploading environment cache artifact...
2021-12-09T14:14:18.309Z [INFO]: # Environment caching completed
Terminating logging...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React App 无法在 AWS Amplify 上部署 - React App unable to deploy on AWS Amplify AWS Amplify Deploy(构建和测试)React JS + Jest + Enzyme - AWS Amplify Deploy (Build & Test) React JS + Jest + Enzyme 如何将带有 nextjs 的 React 应用程序成功部署到 AWS Amplify? - how to deploy successfully React app with nextjs to AWS Amplify? 是否可以使用 aws amplify 构建和部署 cube.js。 如果是,它的构建设置是什么? - Is it possible to build and deploy cube.js using aws amplify. If yes, what would be build settings for it? 尝试在 aws amplify 上部署 react 应用程序,但不断收到“未为工件指定的基本目录,无法创建构建工件”。 - Trying to deploy react app on aws amplify but keep getting a "Base Directory not specified for artifacts, unable to create build artifact." 将 React 应用程序部署到 AWS 时遇到错误 - Encounter error when deploy React app to AWS 在 AWS Amplify 上构建 React 应用程序在 Amplify 控制台中失败 - Build of React application on AWS Amplify fails in Amplify Console React App 无法在 AWS Amplify 上正确重定向 - React App not redirecting properly on AWS Amplify 从 React Amplify APP 访问 AWS Secret - Access AWS Secrets from React Amplify APP 使用 puppeteer 测试 AWS 放大反应应用程序 - Testing with puppeteer an AWS amplify react app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM