При загрузке приложения nextjs в aws amplify произошла ошибка на этапе сборки

#amazon-web-services #next.js #aws-amplify

Вопрос:

 2021-06-24T08:24:16.127Z [INFO]: # Cloning repository: git@github.com:Friel909/rivgurufrontend.git
2021-06-24T08:24:16.136Z [INFO]: Agent pid 134
2021-06-24T08:24:16.171Z [INFO]: Identity added: /root/.ssh/git_rsa (/root/.ssh/git_rsa)
2021-06-24T08:24:16.457Z [INFO]: Cloning into 'rivgurufrontend'...
2021-06-24T08:24:16.730Z [INFO]: Warning: Permanently added the RSA host key for IP address '140.82.113.3' to the list of known hosts.
2021-06-24T08:24:20.145Z [INFO]: # Checking for Git submodules at: /codebuild/output/src574159690/src/rivgurufrontend/.gitmodules
2021-06-24T08:24:20.297Z [WARNING]: !Error: ENOENT: no such file or directory, open '/codebuild/output/src574159690/src/rivgurufrontend/amplify.yml'
2021-06-24T08:24:20.321Z [INFO]: # Retrieving environment cache...
2021-06-24T08:24:20.360Z [INFO]: # Retrieved environment cache
2021-06-24T08:24:20.421Z [INFO]: # Ensuring NPM package '@aws-amplify/cli' is version: 'latest'
2021-06-24T08:24:25.612Z [INFO]: # Patching NPM package '@aws-amplify/cli' from 4.29.4 to 5.0.1...
2021-06-24T08:25:09.935Z [INFO]: # Done patching NPM package '@aws-amplify/cli'
2021-06-24T08:25:17.255Z [INFO]: ## Starting Backend Build
                                 # Starting phase: build
2021-06-24T08:25:27.011Z [INFO]: [0mAmplify AppID found: dmnxn1mt5e02o. Amplify App name is: newAWSSite[0m
2021-06-24T08:25:27.072Z [INFO]: [0mBackend environment dev found in Amplify Console app: newAWSSite[0m
2021-06-24T08:25:27.859Z [WARNING]: - Fetching updates to backend environment: dev from the cloud.
2021-06-24T08:25:28.063Z [WARNING]: ✔ Successfully pulled backend environment dev from the cloud.
2021-06-24T08:25:28.067Z [INFO]: 
2021-06-24T08:25:30.999Z [INFO]: [33mNote: It is recommended to run this command from the root of your app directory[39m
2021-06-24T08:25:35.904Z [WARNING]: - Initializing your environment: dev
2021-06-24T08:25:36.155Z [WARNING]: ✔ Initialized provider successfully.
2021-06-24T08:25:36.435Z [WARNING]: - Updating resources in the cloud. This may take a few minutes...
2021-06-24T08:25:42.065Z [INFO]: 
2021-06-24T08:25:42.067Z [INFO]: UPDATE_IN_PROGRESS amplify-newawssite-dev-151151 AWS::CloudFormation::Stack Thu Jun 24 2021 08:25:36 GMT 0000 (Coordinated Universal Time) User Initiated
                                 UPDATE_IN_PROGRESS UnauthRole                    AWS::IAM::Role             Thu Jun 24 2021 08:25:41 GMT 0000 (Coordinated Universal Time)
                                 UPDATE_IN_PROGRESS AuthRole                      AWS::IAM::Role             Thu Jun 24 2021 08:25:41 GMT 0000 (Coordinated Universal Time)
                                 UPDATE_IN_PROGRESS DeploymentBucket              AWS::S3::Bucket            Thu Jun 24 2021 08:25:41 GMT 0000 (Coordinated Universal Time)
2021-06-24T08:25:57.046Z [INFO]: 
2021-06-24T08:25:57.047Z [INFO]: UPDATE_COMPLETE UnauthRole AWS::IAM::Role Thu Jun 24 2021 08:25:53 GMT 0000 (Coordinated Universal Time)
                                 UPDATE_COMPLETE AuthRole   AWS::IAM::Role Thu Jun 24 2021 08:25:54 GMT 0000 (Coordinated Universal Time)
2021-06-24T08:26:07.060Z [INFO]: 
2021-06-24T08:26:07.062Z [INFO]: UPDATE_COMPLETE                     DeploymentBucket              AWS::S3::Bucket            Thu Jun 24 2021 08:26:02 GMT 0000 (Coordinated Universal Time)
                                 UPDATE_COMPLETE_CLEANUP_IN_PROGRESS amplify-newawssite-dev-151151 AWS::CloudFormation::Stack Thu Jun 24 2021 08:26:04 GMT 0000 (Coordinated Universal Time)
                                 UPDATE_COMPLETE                     amplify-newawssite-dev-151151 AWS::CloudFormation::Stack Thu Jun 24 2021 08:26:05 GMT 0000 (Coordinated Universal Time)
2021-06-24T08:26:07.244Z [WARNING]: - Uploading files...
2021-06-24T08:26:07.303Z [WARNING]: - Uploading files...
2021-06-24T08:26:07.363Z [WARNING]: - Uploading files...
2021-06-24T08:26:07.414Z [WARNING]: ✔ All resources are updated in the cloud
2021-06-24T08:26:07.415Z [INFO]: 
2021-06-24T08:26:07.415Z [INFO]: 
2021-06-24T08:26:07.952Z [INFO]: [32mInitialized your environment successfully.[39m
2021-06-24T08:26:07.953Z [INFO]: [32mYour project has been successfully initialized and connected to the cloud![39m
                                 [32mSome next steps:[39m
                                 [0m"amplify status" will show you what you've added already and if it's locally configured or deployed[0m
                                 [0m"amplify add <category>" will allow you to add features like user login or a backend API[0m
                                 [0m"amplify push" will build all your local backend resources and provision it in the cloud[0m
                                 [0m"amplify console" to open the Amplify Console and view your project status[0m
                                 [0m"amplify publish" will build all your local backend and frontend resources (if you have hosting category added) and provision it in the cloud[0m
                                 [32mPro tip:[39m
                                 [0mTry "amplify add api" to create a backend API and then "amplify publish" to deploy everything[0m
2021-06-24T08:26:10.356Z [INFO]: # Completed phase: build
                                 ## Completed Backend Build
                                 ## Starting Frontend Build
2021-06-24T08:26:10.358Z [INFO]: # Starting phase: preBuild
                                 # Executing command: npm ci
2021-06-24T08:26:18.115Z [INFO]: > core-js@2.6.12 postinstall /codebuild/output/src574159690/src/rivgurufrontend/node_modules/core-js
                                 > node -e "try{require('./postinstall')}catch(e){}"
2021-06-24T08:26:18.326Z [INFO]: > ejs@2.7.4 postinstall /codebuild/output/src574159690/src/rivgurufrontend/node_modules/ejs
                                 > node ./postinstall.js
2021-06-24T08:26:18.361Z [INFO]: Thank you for installing [35mEJS[0m: built with the [32mJake[0m JavaScript build tool ([32mhttps://jakejs.com/[0m)
2021-06-24T08:26:18.533Z [INFO]: > bcrypt@5.0.1 install /codebuild/output/src574159690/src/rivgurufrontend/node_modules/bcrypt
                                 > node-pre-gyp install --fallback-to-build
2021-06-24T08:26:18.689Z [INFO]: [bcrypt] Success: "/codebuild/output/src574159690/src/rivgurufrontend/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node" is installed via remote
2021-06-24T08:26:18.706Z [INFO]: added 946 packages in 8.038s
2021-06-24T08:26:18.716Z [INFO]: # Completed phase: preBuild
                                 # Starting phase: build
2021-06-24T08:26:18.717Z [INFO]: # Executing command: npm run build
2021-06-24T08:26:18.882Z [INFO]: > edemy@1.5.0 build /codebuild/output/src574159690/src/rivgurufrontend
                                 > next build
2021-06-24T08:26:19.813Z [INFO]: info  - Using webpack 4. Reason: custom webpack configuration in next.config.js https://nextjs.org/docs/messages/webpack5
2021-06-24T08:26:20.355Z [INFO]: Attention: Next.js now collects completely anonymous telemetry regarding usage.
2021-06-24T08:26:20.356Z [INFO]: This information is used to shape Next.js' roadmap and prioritize features.
                                 You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
                                 https://nextjs.org/telemetry
2021-06-24T08:26:20.385Z [INFO]: info  - Checking validity of types...
2021-06-24T08:26:20.391Z [INFO]: info  - Creating an optimized production build...
2021-06-24T08:26:20.428Z [INFO]: > [PWA] Compile client (static)
2021-06-24T08:26:20.428Z [INFO]: > [PWA] Auto register service worker with: /codebuild/output/src574159690/src/rivgurufrontend/node_modules/next-pwa/register.js
                                 > [PWA] Service worker: /codebuild/output/src574159690/src/rivgurufrontend/.next/sw.js
                                 > [PWA]   url: /sw.js
                                 > [PWA]   scope: /
2021-06-24T08:26:20.698Z [INFO]: > [PWA] Compile server
2021-06-24T08:26:53.998Z [WARNING]: @rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`.
2021-06-24T08:26:57.000Z [INFO]: info  - Compiled successfully
2021-06-24T08:26:57.000Z [INFO]: info  - Collecting page data...
2021-06-24T08:26:57.615Z [WARNING]: Warning: You have opted-out of Automatic Static Optimization due to `getInitialProps` in `pages/_app`. This does not opt-out pages with `getStaticProps`
2021-06-24T08:26:57.616Z [WARNING]: Read more: https://nextjs.org/docs/messages/opt-out-auto-static-optimization
2021-06-24T08:26:57.626Z [INFO]: info  - Generating static pages (0/1)
2021-06-24T08:26:57.866Z [INFO]: info  - Generating static pages (1/1)
2021-06-24T08:26:57.867Z [INFO]: info  - Finalizing page optimization...
2021-06-24T08:26:57.870Z [INFO]: 
2021-06-24T08:26:57.891Z [INFO]: Page                                                           Size     First Load JS
                                 ┌ λ /                                                          4.17 kB         145 kB
                                 ├   /_app                                                      0 B             107 kB
                                 ├ λ /404                                                       1.87 kB         109 kB
                                 ├ λ /about-1                                                   3.7 kB          121 kB
                                 ├ λ /about-2                                                   2.62 kB         120 kB
                                 ├ λ /about-3                                                   6.27 kB         119 kB
                                 ├ λ /admin/dashboard                                           2.79 kB         110 kB
                                 ├ λ /admin/pending-requests                                    2.08 kB         109 kB
                                 ├ λ /advisor                                                   2.53 kB         109 kB
                                 ├ λ /api/contact                                               0 B             107 kB
                                 ├ λ /api/v1/apply/approve-requests                             0 B             107 kB
                                 ├ λ /api/v1/apply/decline-requests                             0 B             107 kB
                                 ├ λ /api/v1/apply/pending-requests                             0 B             107 kB
                                 ├ λ /api/v1/auth/account                                       0 B             107 kB
                                 ├ λ /api/v1/auth/confirm-email                                 0 B             107 kB
                                 ├ λ /api/v1/auth/forgot-password                               0 B             107 kB
                                 ├ λ /api/v1/auth/password-change                               0 B             107 kB
                                 ├ λ /api/v1/auth/signin                                        0 B             107 kB
                                 ├ λ /api/v1/auth/signup                                        0 B             107 kB
                                 ├ λ /api/v1/courses                                            0 B             107 kB
                                 ├ λ /api/v1/courses/[id]                                       0 B             107 kB
                                 ├ λ /api/v1/courses/checkout                                   0 B             107 kB
                                 ├ λ /api/v1/courses/course/[id]                                0 B             107 kB
                                 ├ λ /api/v1/courses/course/new                                 0 B             107 kB
                                 ├ λ /api/v1/courses/course/remove                              0 B             107 kB
                                 ├ λ /api/v1/courses/course/update                              0 B             107 kB
                                 ├ λ /api/v1/courses/course/video-upload                        0 B             107 kB
                                 ├ λ /api/v1/courses/enrolled                                   0 B             107 kB
                                 ├ λ /api/v1/courses/enrolled/[id]                              0 B             107 kB
                                 ├ λ /api/v1/courses/enrolled/videos                            0 B             107 kB
                                 ├ λ /api/v1/courses/homepage-courses                           0 B             107 kB
                                 ├ λ /api/v1/courses/my-courses                                 0 B             107 kB
                                 ├ λ /api/v1/courses/search                                     0 B             107 kB
                                 ├ λ /api/v1/user/apply                                         0 B             107 kB
                                 ├ λ /authentication                                            5.41 kB         120 kB
                                 ├ λ /become-a-teacher                                          3.76 kB         128 kB
                                 ├ λ /blog-1                                                    2.57 kB         109 kB
                                 ├ λ /blog-2                                                    2.71 kB         110 kB
                                 ├ λ /blog-3                                                    2.69 kB         110 kB
                                 ├ λ /blog-4                                                    3.55 kB         113 kB
                                 ├ λ /cart                                                      2.58 kB         109 kB
                                 ├ λ /categories                                                2.65 kB         110 kB
                                 ├ λ /checkout                                                  3.07 kB         110 kB
                                 ├ λ /coming-soon                                               2.89 kB         110 kB
                                 ├ λ /contact                                                   4.69 kB         138 kB
                                 ├ λ /courses                                                   1.7 kB          109 kB
                                 ├ λ /courses-1                                                 1.36 kB         108 kB
                                 ├ λ /courses-2                                                 3.08 kB         110 kB
                                 ├ λ /courses-3                                                 4.87 kB         112 kB
                                 ├ λ /courses-4                                                 2.84 kB         110 kB
                                 ├ λ /courses-5                                                 2.99 kB         110 kB
                                 ├ λ /courses-6                                                 3.39 kB         110 kB
                                 ├ λ /courses/[id]                                              9.15 kB         123 kB
                                 ├ λ /courses/search                                            1.75 kB         109 kB
                                 ├ λ /distance-learning                                         6.17 kB         116 kB
                                 ├ λ /elearning                                                 7.02 kB         120 kB
                                 ├ λ /events                                                    2.82 kB         110 kB
                                 ├ λ /faq                                                       6.94 kB         117 kB
                                 ├ λ /gallery                                                   16 kB           123 kB
                                 ├ λ /health-coaching                                           5.63 kB         115 kB
                                 ├ λ /kindergaten                                               5.41 kB         115 kB
                                 ├ λ /language-school                                           5.09 kB         115 kB
                                 ├ λ /membership-levels                                         2.67 kB         110 kB
                                 ├ λ /modern-schooling                                          1.68 kB         142 kB
                                 ├ λ /my-courses                                                3.6 kB          110 kB
                                 ├ λ /my-courses/view/[id]                                      3.96 kB         111 kB
                                 ├ λ /online-training                                           4.83 kB         122 kB
                                 ├ λ /privacy-policy                                            3.95 kB         111 kB
                                 ├ λ /products-list-1                                           2.67 kB         110 kB
                                 ├ λ /products-list-2                                           3.18 kB         110 kB
                                 ├ λ /profile                                                   3.63 kB         111 kB
                                 ├ λ /purchase-guide                                            4.2 kB          111 kB
                                 ├ λ /regist                                                    47.2 kB         154 kB
                                 ├ λ /single-blog-1                                             2.73 kB         112 kB
                                 ├ λ /single-blog-2                                             2.8 kB          112 kB
                                 ├ λ /single-blog-3                                             3.36 kB         115 kB
                                 ├ λ /single-courses-1                                          6.69 kB         120 kB
                                 ├ λ /single-courses-2                                          5.45 kB         112 kB
                                 ├ λ /single-events                                             4.07 kB         114 kB
                                 ├ λ /single-products                                           4.39 kB         114 kB
                                 ├ λ /success-story                                             5.77 kB         116 kB
                                 ├ λ /teacher/course/[id]                                       7.42 kB         114 kB
                                 ├ λ /teacher/course/create                                     6.58 kB         113 kB
                                 ├ λ /teacher/course/upload-course-video                        4.99 kB         119 kB
                                 ├ λ /teacher/courses                                           4.43 kB         111 kB
                                 ├ λ /teacher/courses/course-edit                               4.11 kB         111 kB
                                 ├ λ /teacher/dashboard                                         2.85 kB         110 kB
                                 ├ λ /terms-of-service                                          3.98 kB         111 kB
                                 ├ λ /user/edit-password                                        2.01 kB         109 kB
                                 ├ λ /user/edit-profile                                         2.02 kB         109 kB
                                 ├ λ /user/my-profile                                           2.05 kB         109 kB
                                 ├ λ /vendor-certification                                      8.07 kB         121 kB
                                 └ λ /yoga-training                                             7.59 kB         121 kB
                                   First Load JS shared by all                                  107 kB
                                 ├ chunks/11bc2bf37049d64376b67555cfd11e8f5753fb99.f1bb36.js  6.87 kB
                                 ├ chunks/c6464ce45454a8a567d341c8d3b5fce3b9953bc5.e565f0.js  5.11 kB
                                 ├ chunks/ca92af84a5277c2d4f7907f2d3fdddd999dec0ab.a92b9c.js  18.2 kB
                                 ├ chunks/commons.f56827.js                                   13.3 kB
                                 ├ chunks/framework.3105c3.js                                 42.3 kB
                                 ├ chunks/main.19746a.js                                      9.09 kB
                                 ├ chunks/pages/_app.6bbed9.js                                10.8 kB
                                 ├ chunks/webpack.0e2ed6.js                                   1.19 kB
                                 └ css/6355be800e5cb2e052ca.css                               87.8 kB
                                 λ  (Server)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
                                 ○  (Static)  automatically rendered as static HTML (uses no initial props)
                                 ●  (SSG)     automatically generated as static HTML   JSON (uses getStaticProps)
                                 (ISR)     incremental static regeneration (uses revalidate in getStaticProps)
2021-06-24T08:26:58.028Z [INFO]: Starting SSR Build...
2021-06-24T08:27:50.600Z [ERROR]: Error: 'Command failed with exit code 1: node_modules/.bin/next build',
                                  command: 'node_modules/.bin/next build',
                                  exitCode: 1,
                                  signal: undefined,
                                  signalDescription: undefined,
                                  stdout: 'info  - Using webpack 4. Reason: custom webpack configuration in next.config.js https://nextjs.org/docs/messages/webpack5n'  
                                  'info  - Checking validity of types...n'  
                                  'info  - Creating an optimized production build...n'  
                                  '> [PWA] Compile client (static)n'  
                                  '> [PWA] Auto register service worker with: /codebuild/output/src574159690/src/rivgurufrontend/node_modules/next-pwa/register.jsn'  
                                  '> [PWA] Service worker: /codebuild/output/src574159690/src/rivgurufrontend/.next/sw.jsn'  
                                  '> [PWA]   url: /sw.jsn'  
                                  '> [PWA]   scope: /n'  
                                  '> [PWA] Compile server',
                                  stderr: "@rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`.n"  
                                  'Failed to compile.n'  
                                  'n'  
                                  "ModuleNotFoundError: Module not found: Error: Can't resolve 'mock-aws-s3' in '/codebuild/output/src574159690/src/rivgurufrontend/node_modules/@mapbox/node-pre-gyp/lib/util'n"  
                                  'n'  
                                  'n'  
                                  '> Build error occurredn'  
                                  'Error: > Build failed because of webpack errorsn'  
                                  '    at /codebuild/output/src574159690/src/rivgurufrontend/node_modules/next/dist/build/index.js:17:924n'  
                                  '    at runMicrotasks (<anonymous>)n'  
                                  '    at processTicksAndRejections (internal/process/task_queues.js:97:5)n'  
                                  '    at async Span.traceAsyncFn (/codebuild/output/src574159690/src/rivgurufrontend/node_modules/next/dist/telemetry/trace/trace.js:6:584)',
                                  failed: true,
                                  timedOut: false,
                                  isCanceled: false,
Terminating logging...
 

Когда я попытался использовать ContinuousDeployment, я выбрал github и ввел информацию о своем репозитории на github. но затем он показывает эту ошибку на этапе сборки, даже если я думал, что, когда я пытаюсь построить его локально с помощью npm run build, он работает нормально.

Я пробовал использовать много методов, включая использование консоли для ее развертывания и прямое использование усиления, но оба не сработали.

Комментарии:

1. вы уже решили эту проблему? Я также застрял на этой ошибке сборки усиления.