12

The project's pages work fine with npm run dev and I do not get these errors with the pages with vercel --prod. The problems show up when I generate a production build and run the app with next start.

With [email protected] I got TypeError: Cannot read properties of undefined (reading 'ppr') so I downgraded to [email protected]. Now I am getting multiple instances of TypeError: Cannot read properties of undefined (reading 'clientModules')

TypeError: Cannot read properties of undefined (reading 'clientModules') at u (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:108:22420) at /Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:108:23409 at nk (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:38654) at nC (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:54802) at nk (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:51563) at nC (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:54802) at nw (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:38210) at nk (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:38805) at nC (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:54802) at nk (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:51563) TypeError: Cannot read properties of undefined (reading 'clientModules') at u (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:108:22420) at /Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:108:23409 at nk (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:38654) at nC (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:54802) at nj (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:60948) at AsyncLocalStorage.run (node:async_hooks:346:14) at Timeout._onTimeout (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:76278) at listOnTimeout (node:internal/timers:573:17) at process.processTimers (node:internal/timers:514:7) TypeError: Cannot read properties of undefined (reading 'clientModules') at u (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:108:22420) at /Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:108:23409 at nk (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:38654) at nC (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:54802) at nj (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:60948) at AsyncLocalStorage.run (node:async_hooks:346:14) at Timeout._onTimeout (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:76278) at listOnTimeout (node:internal/timers:573:17) at process.processTimers (node:internal/timers:514:7)

1
  • I also have this error without having touched my code. Commented Mar 21, 2024 at 13:45

6 Answers 6

5

The issue that I had was that my routes were conflicting. I had one folder that was (homepage), meaning that the route was effectively "/". However, I also left a page.tsx file in the root directory, which had "/" as its route as well. Make sure that you don't have any overlap between folders that aren't included in the route structure and their root folders.

Sign up to request clarification or add additional context in comments.

2 Comments

I had the exact same issue (home)/page.js and /page.js - 1 stack overflow answer has beaten my endless v0 conversation on its own topic
Same issue here - i was using [...rest] which broke my parallel routes in production but not in development.
3

I had this problem few days ago, for context i was converting my Vite-React-SPA to NextJS for SSR and SSG, then also host it on Vercel (the Vite version was already hosted).

I found the problem from restructuring the filepaths (I was using App router), then i run debug. It's painful way of doing it yes. but i did found the problem.

on my file arch app/(group_folder)/@footer/page, there was a missing import statement here. AND because it was not in the root app/ where homepage(/page) was located, it causes build error for some reason. So the idea was if you're using @slots then don't put them inside other folders and keep them in the root folder of your pages along with the /page.js*jsx.

like this

~app/page.jsx
~app/@footer/page.jsx
~app/@navigation/page.jsx

that's how i fixed this error

TypeError: Cannot read properties of undefined (reading 'clientModules')

Since Im new to this and don't understand the intricacies of server and client components yet i may be wrong with this approach so if anyone can edit this so its more readable i would be more than glad.

2 Comments

so we cant save parallels convention inside (convention) folder ?
but when i triend rm -rf node_modules and tried build again.. there is no error again . but its always error on my CI.yml
2

i solved in my local project just run rm -rf node_modules and tried npm install again its solved .

but in my CI.yml on build still on issue . on CI i alr tried to remove first but still error only on CI . anyone have tricks or solution ?

engine :

"typescript": "^5.3.3"
"tailwindcss": "^3.4.1",
"tsx": "^4.7.1",
...
.....
"next": "^14.1.1",

Comments

0

I Have same issue in Next js 14.2 due to nested page.js or page.tsx in folders... so need to remove extra page.js

Comments

0

I had the same build error using Next v14.2 - some detail below and my solution in case this helps anyone with a similar issue.

The original file structure using the App router was:

app
|-- index
|   |-- sectionOne
|   |   |-- page.tsx
|   |-- sectionTwo
|   |   |-- page.tsx
|   |-- page.tsx
|-- page.tsx

This gave routes of '/', '/index' and nested routes of '/index/sectionOne' and 'index/sectionTwo'.

This worked OK using the local dev server but when trying to build for production threw the error 'TypeError: Cannot read properties of undefined (reading 'clientModules')'

I (eventually) worked out that there was an issue with the '/' site index/landing page and the '/index' route folder name that appeared to be causing the problem and confusing the build process.

Keeping the original file structure and renaming the 'index' folder to 'sections' (e.g 'sections/sectionOne') fixed the issue.

Comments

0

i had this issue as well (in next.js 14), at first i seperated my folders in app.js (directly) into both folders (main) and dashboard

app
----(main)
----------login
----------profile
----dashboard
----------products

which gets this error, in main there are many pages and i get this error. folder structure in main folder were something like this

app/(main)/profile/page.js

i removed (main) in app.js and transfer all folders in app.js directly, not in brackes (main) and edited like this

app/profile/page.js

the error gone

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.