Build occasionally fails complains about missing modules but also succeeds
See original GitHub issueBug report
Describe the bug
I have a fairly simple app that pings a mongo database and generates dynamic pages. The homepage lists a handful of documents and they link to individual pages. The build often fails complaining about missing modules despite running perfectly fine on localhost. However, if I build it a 2nd or 3rd time it will usually succeed.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Clone https://github.com/itsclarke/vantures
- Install dependencies
- Run
npm run dev
- While dev is running, also run
npm run build
- See errors
Expected behavior
A failed build outputs:
> next build
info - Loaded env from ~/app/.env.local
Creating an optimized production build
Compiled successfully.
Automatically optimizing pages .
Error occurred prerendering page "/rental/new". Read more: https://err.sh/next.js/prerender-error
Error: Cannot find module for page: /rental/new
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)
Error occurred prerendering page "/rental/10051164". 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)
Error occurred prerendering page "/rental/10082307". 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)
Error occurred prerendering page "/rental/10138784". 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)
Error occurred prerendering page "/rental/10057826". 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)
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)
Error occurred prerendering page "/". Read more: https://err.sh/next.js/prerender-error
Error: Cannot find module for page: /
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
/rental/new
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)
When it succeeds the build outputs:
info - Loaded env from /Users/brianclarke/Documents/development/next-vanture/.env.local
Creating an optimized production build
Compiled successfully.
Automatically optimizing pages .Could not find files for /rental/new in .next/build-manifest.json
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
But the other server running the API code outputs this as well:
the options [servers] is not supported
the options [caseTranslate] is not supported
the options [dbName] is not supported
the options [srvHost] is not supported
the options [credentials] is not supported
the options [servers] is not supported
the options [caseTranslate] is not supported
the options [dbName] is not supported
the options [srvHost] is not supported
the options [credentials] is not supported
the options [username] is not supported
the server/replset/mongos/db options are deprecated, all their options are supported at the top level of the options object [poolSize,ssl,sslValidate,sslCA,sslCert,sslKey,sslPass,sslCRL,autoReconnect,noDelay,keepAlive..
System information
- OS: macOS
- Version of Next.js: 9.5.1
- Version of Node.js: 14.5.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:24 (1 by maintainers)
Top Results From Across the Web
NextJS build occasionally fails then succeeds - Stack Overflow
I'm playing around with NextJS and things appear to be fine when running in development but when I build the app it will...
Read more >Module compiles, but editor shows compilation issues
Hello,. I have the same kind of problem. The module is compiling with success. But the editor shows me red errors for the...
Read more >How to fix "The following module is missing from the file ...
Restore the module and actually disable and uninstall it (recommended if possible): First, restore the module to its original location in the file...
Read more >Errors compiling with STMCubeIDE likely because module ...
The missing modules seem to have been included with this change. ... I also have this problem, and have gotten around it by...
Read more >Common Build Problems - Travis CI Docs
Check the list of dependencies in the build log, usually output including versions and see, if there's anything that's changed. Sometimes, this can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@touqeeraslam I haven’t been able to solve it. Ended up not using NextJS because the contributors never got back to me.
Any idea on how one would go about fixing this?