React 来自 AWS Amplify 的应用程序构建错误

问题描述 投票:0回答:1

您好,我正在尝试通过将其连接到我的 GitHub 分支来在 Amplify 上部署我的 React 应用程序。它给了我一个构建错误,但我不认为我做错了什么。同一个 GitHub 分支连接到 Netlify,并且工作完全正常。 这些是 Amplify 上的构建设置

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - npm install
    build:
      commands:
        - npm run build
  artifacts:
    baseDirectory: build
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

packages.json

{
    "name": "x-spreadsheet-react",
    "version": "1.0.0",
    "description": "",
    "keywords": [],
    "main": "src/index.js",
    "dependencies": {
        "axios": "^0.26.1",
        "react": "16.12.0",
        "react-apexcharts": "^1.3.9",
        "react-dom": "16.12.0",
        "react-hot-toast": "^2.2.0",
        "react-icons": "^4.3.1",
        "react-redux": "^7.2.6",
        "react-router-dom": "^5.3.0",
        "react-scripts": "3.0.1",
        "redux": "^4.1.2",
        "redux-devtools-extension": "^2.13.9",
        "redux-persist": "^6.0.0",
        "redux-thunk": "^2.4.1",
        "x-data-spreadsheet": "1.1.6",
        "xlsx": "^0.16.5"
    },
    "devDependencies": {
        "typescript": "3.8.3"
    },
    "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",
        "test": "react-scripts test --env=jsdom",
        "eject": "react-scripts eject"
    },
    "browserslist": [
        ">0.2%",
        "not dead",
        "not ie <= 11",
        "not op_mini all"
    ]
}

节点版本16.8.0

这是我在构建错误后得到的日志文件

2022-03-13T09:28:23.339Z [INFO]: Git SSH Key acquired
2022-03-13T09:28:23.415Z [INFO]: # Cloning repository: [email protected]:ahsan44411/excel.git
2022-03-13T09:28:23.638Z [INFO]: Agent pid 135
2022-03-13T09:28:23.661Z [INFO]: Identity added: /root/.ssh/git_rsa (/root/.ssh/git_rsa)
2022-03-13T09:28:24.096Z [INFO]: Cloning into 'excel'...
2022-03-13T09:28:24.521Z [INFO]: Warning: Permanently added the ECDSA host key for IP address '140.82.114.3' to the list of known hosts.
2022-03-13T09:28:25.062Z [INFO]: # Switching to commit: 1010ba54dd4ab706c46f3f593ccd68a2082d2fd5
2022-03-13T09:28:25.090Z [INFO]: Agent pid 148
2022-03-13T09:28:25.091Z [INFO]: Identity added: /root/.ssh/git_rsa (/root/.ssh/git_rsa)
                                 Note: switching to '1010ba54dd4ab706c46f3f593ccd68a2082d2fd5'.
                                 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 1010ba5 Delete package-lock.json
2022-03-13T09:28:25.133Z [INFO]: Successfully cleaned up Git credentials
2022-03-13T09:28:25.133Z [INFO]: # Checking for Git submodules at: /codebuild/output/src366852352/src/excel/.gitmodules
2022-03-13T09:28:25.155Z [INFO]: # Retrieving environment cache...
2022-03-13T09:28:25.182Z [INFO]: # Retrieved environment cache
2022-03-13T09:28:25.182Z [INFO]: ---- Setting Up SSM Secrets ----
2022-03-13T09:28:25.182Z [INFO]: SSM params {"Path":"/amplify/d1x5u7awp8tlr9/main/","WithDecryption":true}
2022-03-13T09:28:25.210Z [WARNING]: !Failed to set up process.env.secrets
2022-03-13T09:28:25.211Z [INFO]: No live updates for this build run
2022-03-13T09:28:25.218Z [INFO]: # Retrieving cache...
2022-03-13T09:28:25.251Z [INFO]: # Extracting cache...
2022-03-13T09:28:25.258Z [INFO]: # Extraction completed
2022-03-13T09:28:53.823Z [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 install
2022-03-13T09:28:57.866Z [WARNING]: npm WARN deprecated [email protected]: Package moved to @redux-devtools/extension.
2022-03-13T09:28:58.099Z [WARNING]: npm WARN deprecated [email protected]: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
2022-03-13T09:28:58.754Z [WARNING]: npm WARN deprecated [email protected]: This loader has been deprecated. Please use eslint-webpack-plugin
2022-03-13T09:28:59.077Z [WARNING]: npm WARN
2022-03-13T09:28:59.077Z [WARNING]: deprecated [email protected]: please switch to a stable version
2022-03-13T09:29:00.028Z [WARNING]: npm WARN
2022-03-13T09:29:00.028Z [WARNING]: deprecated [email protected]: "Please update to latest v2.3 or v2.2"
2022-03-13T09:29:03.426Z [WARNING]: npm
2022-03-13T09:29:03.428Z [WARNING]: WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
2022-03-13T09:29:05.775Z [WARNING]: npm WARN deprecated [email protected]: This SVGO version is no longer supported. Upgrade to v2.x.x.
2022-03-13T09:29:07.006Z [WARNING]: npm WARN
2022-03-13T09:29:07.008Z [WARNING]: deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
2022-03-13T09:29:07.088Z [WARNING]: npm WARN deprecated [email protected]: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
2022-03-13T09:29:08.379Z [WARNING]: npm WARN deprecated
2022-03-13T09:29:08.379Z [WARNING]: [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
2022-03-13T09:29:09.392Z [WARNING]: npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
2022-03-13T09:29:09.400Z [WARNING]: npm WARN deprecated [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
2022-03-13T09:29:09.735Z [WARNING]: npm WARN deprecated @hapi/[email protected]: Switch to 'npm install joi'
2022-03-13T09:29:10.388Z [WARNING]: npm WARN deprecated [email protected]: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added
2022-03-13T09:29:10.837Z [WARNING]: npm WARN deprecated [email protected]: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
2022-03-13T09:29:11.417Z [WARNING]: npm WARN deprecated [email protected]: this library is no longer supported
2022-03-13T09:29:11.607Z [WARNING]: npm WARN deprecated [email protected]: flatten is deprecated in favor of utility frameworks such as lodash.
2022-03-13T09:29:13.294Z [WARNING]: npm WARN deprecated @hapi/[email protected]: This version has been deprecated and is no longer supported or maintained
2022-03-13T09:29:13.339Z [WARNING]: npm WARN deprecated @hapi/[email protected]: This version has been deprecated and is no longer supported or maintained
2022-03-13T09:29:13.340Z [WARNING]: npm WARN deprecated
2022-03-13T09:29:13.340Z [WARNING]: @hapi/[email protected]: This version has been deprecated and is no longer supported or maintained
2022-03-13T09:29:13.341Z [WARNING]: npm WARN
2022-03-13T09:29:13.341Z [WARNING]: deprecated @hapi/[email protected]: Moved to 'npm install @sideway/address'
2022-03-13T09:29:14.648Z [WARNING]: npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
2022-03-13T09:29:14.662Z [WARNING]: npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
2022-03-13T09:29:15.208Z [WARNING]: npm WARN deprecated [email protected]: use String.prototype.padStart()
2022-03-13T09:29:31.947Z [INFO]: > [email protected] postinstall /codebuild/output/src366852352/src/excel/node_modules/babel-polyfill/node_modules/core-js
                                 > node -e "try{require('./postinstall')}catch(e){}"
2022-03-13T09:29:32.001Z [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
2022-03-13T09:29:32.008Z [INFO]: > [email protected] postinstall /codebuild/output/src366852352/src/excel/node_modules/babel-runtime/node_modules/core-js
                                 > node -e "try{require('./postinstall')}catch(e){}"
2022-03-13T09:29:32.077Z [INFO]: > [email protected] postinstall /codebuild/output/src366852352/src/excel/node_modules/core-js
                                 > node -e "try{require('./postinstall')}catch(e){}"
2022-03-13T09:29:32.128Z [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
2022-03-13T09:29:32.412Z [INFO]: > [email protected] postinstall /codebuild/output/src366852352/src/excel/node_modules/x-data-spreadsheet
                                 > opencollective-postinstall
2022-03-13T09:29:32.461Z [INFO]: [96m[1mThank you for using x-data-spreadsheet![96m[1m
2022-03-13T09:29:32.461Z [INFO]: [0m[96mIf you rely on this package, please consider supporting our open collective:[22m[39m
                                 > [94mhttps://opencollective.com/x-spreadsheet/donate[0m
2022-03-13T09:29:33.130Z [WARNING]: npm notice
2022-03-13T09:29:33.131Z [WARNING]: created a lockfile as package-lock.json. You should commit this file.
2022-03-13T09:29:33.137Z [WARNING]: npm
2022-03-13T09:29:33.137Z [WARNING]: WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/react-scripts/node_modules/fsevents):
                                    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2022-03-13T09:29:33.142Z [WARNING]: npm
2022-03-13T09:29:33.142Z [WARNING]: WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/jest-haste-map/node_modules/fsevents):
                                    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2022-03-13T09:29:33.148Z [WARNING]: npm
2022-03-13T09:29:33.148Z [WARNING]: WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/chokidar/node_modules/fsevents):
                                    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2022-03-13T09:29:33.152Z [WARNING]: npm WARN
2022-03-13T09:29:33.152Z [WARNING]: optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules/watchpack/node_modules/chokidar/node_modules/fsevents):
                                    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2022-03-13T09:29:33.158Z [WARNING]: npm WARN
2022-03-13T09:29:33.158Z [WARNING]: [email protected] requires a peer of apexcharts@^3.18.0 but none is installed. You must install peer dependencies yourself.
2022-03-13T09:29:33.164Z [WARNING]: npm WARN
2022-03-13T09:29:33.164Z [WARNING]: @babel/[email protected] requires a peer of @babel/core@^7.13.0 but none is installed. You must install peer dependencies yourself.
2022-03-13T09:29:33.172Z [WARNING]: npm WARN
2022-03-13T09:29:33.172Z [WARNING]: @babel/[email protected] requires a peer of @babel/core@^7.12.0 but none is installed. You must install peer dependencies yourself.
2022-03-13T09:29:33.177Z [WARNING]: npm
2022-03-13T09:29:33.177Z [WARNING]: WARN [email protected] No description
2022-03-13T09:29:33.182Z [WARNING]: npm
2022-03-13T09:29:33.182Z [WARNING]: WARN [email protected] No repository field.
2022-03-13T09:29:33.187Z [WARNING]: npm
2022-03-13T09:29:33.187Z [WARNING]: WARN [email protected] No license field.
2022-03-13T09:29:33.187Z [WARNING]: 
2022-03-13T09:29:33.192Z [INFO]: added 1568 packages from 764 contributors and audited 1573 packages in 37.866s
2022-03-13T09:29:33.686Z [INFO]: 72 packages are looking for funding
                                 run `npm fund` for details
2022-03-13T09:29:33.687Z [INFO]: found 72 vulnerabilities (3 low, 59 moderate, 9 high, 1 critical)
                                 run `npm audit fix` to fix them, or `npm audit` for details
2022-03-13T09:29:33.722Z [INFO]: # Completed phase: preBuild
                                 # Starting phase: build
2022-03-13T09:29:33.722Z [INFO]: # Executing command: npm run build
2022-03-13T09:29:33.899Z [INFO]: > [email protected] build /codebuild/output/src366852352/src/excel
                                 > react-scripts build
2022-03-13T09:29:34.880Z [INFO]: Creating an optimized production build...
2022-03-13T09:29:43.407Z [INFO]: Failed to compile.
2022-03-13T09:29:43.409Z [INFO]: ./node_modules/react-apexcharts/dist/react-apexcharts.min.js
                                 Cannot find module: 'apexcharts/dist/apexcharts.common'. Make sure this package is installed.
                                 You can install this package by running: npm install apexcharts/dist/apexcharts.common.
2022-03-13T09:29:43.436Z [WARNING]: npm
2022-03-13T09:29:43.437Z [WARNING]: ERR! code ELIFECYCLE
                                    npm ERR! errno 1
2022-03-13T09:29:43.439Z [WARNING]: npm
2022-03-13T09:29:43.439Z [WARNING]: ERR! [email protected] build: `react-scripts build`
                                    npm ERR! Exit status 1
                                    npm ERR!
                                    npm ERR! Failed at the [email protected] build script.
                                    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2022-03-13T09:29:43.443Z [WARNING]: 
2022-03-13T09:29:43.443Z [WARNING]: npm ERR! A complete log of this run can be found in:
                                    npm ERR!     /root/.npm/_logs/2022-03-13T09_29_43_439Z-debug.log
2022-03-13T09:29:43.443Z [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/v14.18.1/bin/node',
                                 1 verbose cli   '/root/.nvm/versions/node/v14.18.1/bin/npm',
                                 1 verbose cli   'run',
                                 1 verbose cli   'build'
                                 1 verbose cli ]
                                 2 info using [email protected]
                                 3 info using [email protected]
                                 4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
                                 5 info lifecycle [email protected]~prebuild: [email protected]
                                 6 info lifecycle [email protected]~build: [email protected]
                                 7 verbose lifecycle [email protected]~build: unsafe-perm in lifecycle true
                                 8 verbose lifecycle [email protected]~build: PATH: /root/.nvm/versions/node/v14.18.1/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/codebuild/output/src366852352/src/excel/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/.nvm/versions/node/v14.18.1/bin:/root/.local/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 [email protected]~build: CWD: /codebuild/output/src366852352/src/excel
                                 10 silly lifecycle [email protected]~build: Args: [ '-c', 'react-scripts build' ]
                                 11 silly lifecycle [email protected]~build: Returned: code: 1  signal: null
                                 12 info lifecycle [email protected]~build: Failed to exec build script
                                 13 verbose stack Error: [email protected] build: `react-scripts build`
                                 13 verbose stack Exit status 1
                                 13 verbose stack     at EventEmitter.<anonymous> (/root/.nvm/versions/node/v14.18.1/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
                                 13 verbose stack     at EventEmitter.emit (events.js:400:28)
                                 13 verbose stack     at ChildProcess.<anonymous> (/root/.nvm/versions/node/v14.18.1/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
                                 13 verbose stack     at ChildProcess.emit (events.js:400:28)
                                 13 verbose stack     at maybeClose (internal/child_process.js:1058:16)
                                 13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)
                                 14 verbose pkgid [email protected]
                                 15 verbose cwd /codebuild/output/src366852352/src/excel
                                 16 verbose Linux 4.14.252-195.483.amzn2.x86_64
                                 17 verbose argv "/root/.nvm/versions/node/v14.18.1/bin/node" "/root/.nvm/versions/node/v14.18.1/bin/npm" "run" "build"
                                 18 verbose node v14.18.1
                                 19 verbose npm  v6.14.15
                                 20 error code ELIFECYCLE
                                 21 error errno 1
                                 22 error [email protected] build: `react-scripts build`
                                 22 error Exit status 1
                                 23 error Failed at the [email protected] build script.
                                 23 error This is probably not a problem with npm. There is likely additional logging output above.
                                 24 verbose exit [ 1, true ]
2022-03-13T09:29:43.446Z [ERROR]: !!! Build failed
2022-03-13T09:29:43.446Z [ERROR]: !!! Non-Zero Exit Code detected
2022-03-13T09:29:43.447Z [INFO]: # Starting environment caching...
2022-03-13T09:29:43.447Z [INFO]: # Environment caching completed
Terminating logging...

有人遇到过同样的问题吗?我被困了一段时间,找不到解决方案。 谢谢

reactjs amazon-web-services aws-amplify
1个回答
0
投票

请将节点版本 v6.14.15 更新至 v14.18.1 或最新版本。 可能存在运行过时版本的 Node.js 的控制台映像。要修复,请执行以下操作:

  1. 转到构建设置
  2. 滚动到底部,构建图像设置
  3. 单击[编辑]按钮
  4. 点击【添加包版本覆盖】
  5. 选择节点,版本最新,然后【保存】
© www.soinside.com 2019 - 2024. All rights reserved.