我正在使用NextJS,在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
有什么想法为什么偶尔会失败吗?