Следующая JS сборка иногда дает сбой, а затем завершается успешно - PullRequest
1 голос
/ 04 августа 2020

Я играю с Next JS, и при работе в development все выглядит нормально, но когда я создаю приложение, оно иногда будет жаловаться на отсутствующие модули, несмотря на успешную компиляцию.

Вот результат неудачной попытки:

info  - Loaded env from /app/.env.local
Creating an optimized production build  

Compiled successfully.

Automatically optimizing pages .
Error occurred prerendering page "/rental/10059872". Read more: https://err.sh/next.js/prerender-error
Error: Cannot find module for page: /rental/[id]
    at pageNotFoundError (/app/node_modules/next/dist/next-server/server/require.js:1:384)
    at getPagePath (/app/node_modules/next/dist/next-server/server/require.js:2:82)
    at requirePage (/app/node_modules/next/dist/next-server/server/require.js:2:227)
    at loadComponents (/app/node_modules/next/dist/next-server/server/load-components.js:1:771)
    at Object.exportPage [as default] (/app/node_modules/next/dist/export/worker.js:14:188)

> Build error occurred
Error: Export encountered errors on following paths:
        /rental/10051164
        /rental/10057826
        /rental/10059872
        /rental/10082307
        /rental/10138784
    at exportApp (/app/node_modules/next/dist/export/index.js:24:1103)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async build (/app/node_modules/next/dist/build/index.js:37:218)

Вот результат успешной сборки, которая произошла с моей третьей попытки, несмотря на то, что ничего не изменилось:

info  - Loaded env from /app/.env.local
Creating an optimized production build  

Compiled successfully.

Automatically optimizing pages .Could not find files for /rental/[id] in .next/build-manifest.json
Automatically optimizing pages  

Page                              Size     First Load JS
┌ ● /                             3.89 kB        62.7 kB
├   /_app                         0 B            58.8 kB
├ ○ /404                          3.02 kB        61.9 kB
├ λ /api/rental/[id]              0 B            58.8 kB
├ λ /api/rental/new               0 B            58.8 kB
├ λ /api/results                  0 B            58.8 kB
├ ● /rental/[id]                  1.42 kB        60.2 kB
├   ├ /rental/10059872
├   ├ /rental/10051164
├   ├ /rental/10082307
├   └ [+2 more paths]
└ ○ /rental/new                   54.2 kB         113 kB
+ First Load JS shared by all     58.8 kB
├ chunks/commons.90eb9f.js      10.2 kB
├ chunks/framework.9862e0.js    40.5 kB
├ chunks/main.68a017.js         6.73 kB
├ chunks/pages/_app.7abee3.js   280 B
├ chunks/webpack.f300b4.js      1.19 kB
└ css/fafd01249af2219e34a0.css  194 B

λ  (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)

Redirects

┌ source: /:path+/
├ destination: /:path+
└ permanent: true

Есть идеи, почему это время от времени дает сбой?

...