Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: Cannot read properties of undefined (reading 'default') at resolveModuleMetaData #42402

Closed
1 task done
JustinPraas opened this issue Nov 3, 2022 · 18 comments
Labels
area: app App directory (appDir: true)

Comments

@JustinPraas
Copy link

JustinPraas commented Nov 3, 2022

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

$ npx --no-install next info

    Operating System:
      Platform: win32
      Arch: x64
      Version: Windows 10 Pro   
    Binaries:
      Node: 16.18.0
      npm: N/A
      Yarn: N/A
      pnpm: N/A
    Relevant packages:
      next: 13.0.1
      eslint-config-next: 12.0.9
      react: 18.2.0
      react-dom: 18.2.0

warn  - Latest canary version not detected, detected: "13.0.1", newest: "13.0.2-canary.2"

Experimental features used: appDir

What browser are you using? (if relevant)

Chrome (107.0.5304.88) / FireFox (106.0.3)

How are you deploying your application? (if relevant)

next dev

Describe the Bug

Note: Experimental features used: appDir

I have the following project setup (also see repo):
image

When I yarn dev and navigate to http://localhost:3000/route1, all is fine. Then, when I use the navigation bar to navigate to the other route (route2) I sometimes get the following error:

Uncaught TypeError: Cannot read properties of undefined (reading 'default')
    at resolveModuleMetaData (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:195:82)
    at serializeModuleReference (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1298:50)
    at resolveModelToJSON (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1660:40)
    at Array.toJSON (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1081:40)
    at stringify (<anonymous>)
    at processModelChunk (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:163:36)
    at retryTask (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1823:50)
    at performWork (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1856:33)
    at AsyncLocalStorage.run (node:async_hooks:330:14)
    at eval (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1934:55)
resolveErrorDev @ client.js?234c:691
processFullRow @ client.js?234c:756
processBinaryChunk @ client.js?234c:789
progress @ client.js?234c:842

--------------------------------------------------------------------------------------------------------------

react-dom.development.js?160d:21285 The above error occurred in the <ServerRoot> component:
    at ServerRoot (webpack-internal:///./node_modules/next/dist/client/app-index.js:114:11)
    at RSCComponent
    at Root (webpack-internal:///./node_modules/next/dist/client/app-index.js:130:11)

Routing back and forth between route1 and route2 gives me the error 100% of the time

However, one clue:

Note that I have 'use client' on both pages for route1 and route2. When I remove either one of the 'use client' lines of the pages, the app works as expected. Why is this?

Expected Behavior

No error should occur when routing manually using the navigation bar.

Link to reproduction

https://github.com/JustinPraas/next13

To Reproduce

  1. Check out specified repo
  2. yarn install
  3. yarn dev
  4. Go to http://localhost:3000/route1 or http://localhost:3000/route2
  5. Now navigate to the other route (route1/route2 or vice versa) using the navigation bar
  6. Repeat step 5 until the mentioned error comes up in the console and the page stops rendering
@JustinPraas JustinPraas added the bug Issue was opened via the bug report template. label Nov 3, 2022
@nx-jan-fischer
Copy link

nx-jan-fischer commented Nov 3, 2022

I get the same error if I make a clean installation and just create a new page under e.g. /app/blog/page.tsx. And I have not added 'use client'.

@0xmzk
Copy link

0xmzk commented Nov 3, 2022

+1. This proj. (https://stackblitz.com/edit/nextjs-vsc9lp?file=README.md) builds fine on Stackblitz with npm run build but produces that error on my workstation.

    Operating System:
      Platform: win32
      Arch: x64
      Version: Windows 10 Home
    Binaries:
      Node: 16.14.2
      npm: N/A
      Yarn: N/A
      pnpm: N/A
    Relevant packages:
      next: 13.0.2-canary.2
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0

Error:

info  - Collecting page data  
[    ] info  - Generating static pages (0/4)TypeError: Cannot read properties of undefined (reading 'default')
    at Oa (C:\Users\mzkpr\Desktop\nextjs-vsc9lp\.next\server\chunks\565.js:989:56)
    at Ia (C:\Users\mzkpr\Desktop\nextjs-vsc9lp\.next\server\chunks\565.js:1102:50)
    at Array.toJSON (C:\Users\mzkpr\Desktop\nextjs-vsc9lp\.next\server\chunks\565.js:879:32)
    at stringify (<anonymous>)
    at S (C:\Users\mzkpr\Desktop\nextjs-vsc9lp\.next\server\chunks\565.js:1177:51)
    at Object.start (C:\Users\mzkpr\Desktop\nextjs-vsc9lp\.next\server\chunks\565.js:1288:53)
    at g (C:\Users\mzkpr\Desktop\nextjs-vsc9lp\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:102:35)
    at Object.start (C:\Users\mzkpr\Desktop\nextjs-vsc9lp\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:1708:29)
    at Oe.n2 (C:\Users\mzkpr\Desktop\nextjs-vsc9lp\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:770:39)
    at C:\Users\mzkpr\Desktop\nextjs-vsc9lp\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:776:385
[Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.] {
}

Error occurred prerendering page "/action1". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: Cannot read properties of undefined (reading 'default')
    at Oa (C:\Users\mzkpr\Desktop\nextjs-vsc9lp\.next\server\chunks\565.js:989:56)
    at Ia (C:\Users\mzkpr\Desktop\nextjs-vsc9lp\.next\server\chunks\565.js:1102:50)
    at Array.toJSON (C:\Users\mzkpr\Desktop\nextjs-vsc9lp\.next\server\chunks\565.js:879:32)
    at stringify (<anonymous>)
    at S (C:\Users\mzkpr\Desktop\nextjs-vsc9lp\.next\server\chunks\565.js:1177:51)
    at Object.start (C:\Users\mzkpr\Desktop\nextjs-vsc9lp\.next\server\chunks\565.js:1288:53)
    at g (C:\Users\mzkpr\Desktop\nextjs-vsc9lp\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:102:35)
    at Object.start (C:\Users\mzkpr\Desktop\nextjs-vsc9lp\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:1708:29)
    at Oe.n2 (C:\Users\mzkpr\Desktop\nextjs-vsc9lp\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:770:39)
    at C:\Users\mzkpr\Desktop\nextjs-vsc9lp\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:776:385
info  - Generating static pages (4/4)

> Build error occurred
Error: Export encountered errors on following paths:
        /action1/page: /action1
    at C:\Users\mzkpr\Desktop\nextjs-vsc9lp\node_modules\next\dist\export\index.js:408:19
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Span.traceAsyncFn (C:\Users\mzkpr\Desktop\nextjs-vsc9lp\node_modules\next\dist\trace\trace.js:79:20)
    at async C:\Users\mzkpr\Desktop\nextjs-vsc9lp\node_modules\next\dist\build\index.js:1285:21
    at async Span.traceAsyncFn (C:\Users\mzkpr\Desktop\nextjs-vsc9lp\node_modules\next\dist\trace\trace.js:79:20)
    at async C:\Users\mzkpr\Desktop\nextjs-vsc9lp\node_modules\next\dist\build\index.js:1145:17
    at async Span.traceAsyncFn (C:\Users\mzkpr\Desktop\nextjs-vsc9lp\node_modules\next\dist\trace\trace.js:79:20)
    at async Object.build [as default] (C:\Users\mzkpr\Desktop\nextjs-vsc9lp\node_modules\next\dist\build\index.js:64:29)

@JustinPraas
Copy link
Author

Yes, I have the same issue here. The project runs fine on codesandbox, but not on my machine (Windows as well). Feels like this is an OS issue...

@0xmzk
Copy link

0xmzk commented Nov 3, 2022 via email

@JustinPraas
Copy link
Author

Good thinking. And yeah, just tested this on my linux machine (Ubuntu 16.04 lol) and it works as expected. A bit unfortunate. Hope this will get fixed soon.

@HoracioGutierrez
Copy link

Still same issue here

@laurent512
Copy link

I have this issue as well

@yonycalsin
Copy link

I'm getting the same error

[] info  - Generating static pages (0/14654) TypeError: Cannot read properties of undefined (reading '')

[Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.] {
  digest: <code>
}

@PouletteMC
Copy link

I'm getting this issue with both Link and Image when using server side components

@dilvane
Copy link

dilvane commented Nov 5, 2022

Same issue with the 13.0.1 version, but working with the latest 13.0.3-canary.0.

@imranbarbhuiya
Copy link
Contributor

This was fixed in #42421

@Anirban20001962
Copy link

I have the same issue.

@laurent512
Copy link

Indeed, it appears that just updated next with the following version seems to work :
npm install next@13.0.3-canary.0

@Anirban20001962
Copy link

Anirban20001962 commented Nov 6, 2022

Guys so this problem got fixed so should we close this issue?

@timneutkens timneutkens added area: app App directory (appDir: true) kind: bug and removed bug Issue was opened via the bug report template. labels Nov 6, 2022
@timneutkens
Copy link
Member

Installed a new windows machine to verify this: in 13.0.1 it's broken, 13.0.2 is fixed. Going to close this issue. If you're running into something similar @Anirban20001962 please open a new issue with a reproduction. Thanks!

@bhojkamal
Copy link

I got same error on next 13 on my window 10 but on my team linux and mac, it is working with this error.
What wrong here?

2react-dom.development.js:18494 Uncaught TypeError: Cannot read properties of undefined (reading 'default')
    at resolveModuleMetaData (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:195:82)
    at serializeModuleReference (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1298:50)
    at resolveModelToJSON (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1660:40)
    at Array.toJSON (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1081:40)
    at stringify (<anonymous>)
    at processModelChunk (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:163:36)
    at retryTask (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1823:50)
    at performWork (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1856:33)
    at AsyncLocalStorage.run (node:async_hooks:327:14)
    at eval (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1934:55)
resolveErrorDev @ client.js:692
processFullRow @ client.js:757
processBinaryChunk @ client.js:790
progress @ client.js:843
react_devtools_backend.js:4026 The above error occurred in the <ServerRoot> component:

    at ServerRoot (webpack-internal:///./node_modules/next/dist/client/app-index.js:113:11)
    at RSCComponent
    at Root (webpack-internal:///./node_modules/next/dist/client/app-index.js:130:11)

Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries.

index.js:11 Uncaught TypeError: Cannot read properties of undefined (reading 'default')
    at resolveModuleMetaData (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:195:82)
    at serializeModuleReference (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1298:50)
    at resolveModelToJSON (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1660:40)
    at Array.toJSON (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1081:40)
    at stringify (<anonymous>)
    at processModelChunk (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:163:36)
    at retryTask (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1823:50)
    at performWork (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1856:33)
    at AsyncLocalStorage.run (node:async_hooks:327:14)
    at eval (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1934:55)

@bhojkamal
Copy link

bhojkamal commented Nov 22, 2022

Okay, Now I changed next to 13.0.4 from 13.0.1. This error gone.
Thanks.

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: app App directory (appDir: true)
Projects
None yet
Development

No branches or pull requests