next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Navigating between server component + client component page throws error - Cannot read properties of undefined (reading '')

Open james-elicx opened this issue 1 year ago • 35 comments

Verify canary release

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

Provide environment information

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

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

When I visit a server component page and then visit a client component page, I will no longer be able to access the server component page I previously accessed. This is the same case when you have client components inside server component pages.

Flow:

  1. Run the Next.js app in development mode.
  2. Visit root server component page, i.e. /
  3. Visit client component page, i.e. /client-page
  4. Visit root server component page, i.e. /

Result: A white page and an error in my terminal/console.

event - compiled client and server successfully in 434 ms (198 modules)
wait  - compiling /page (client and server)...
event - compiled client and server successfully in 206 ms (333 modules)
wait  - compiling /client-page/page (client and server)...
event - compiled client and server successfully in 124 ms (345 modules)
TypeError: Cannot read properties of undefined (reading '')
    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)
TypeError: Cannot read properties of undefined (reading '')
    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) {
  digest: '1544633764'
}

Expected Behavior

The page should render normally.

Link to reproduction

https://github.com/james-elicx/nextjs13-client-server-error-reproduction

To Reproduce

  1. Run the Next.js app in development mode.
  2. Visit root server component page, i.e. /
  3. Visit client component page, i.e. /client-page
  4. Visit root server component page, i.e. /

james-elicx avatar Oct 25 '22 21:10 james-elicx

Same things happens to me but all pages are on client. Also my links don't work i have to change page manually. I have no clue what this can be.

VincentGillot avatar Oct 26 '22 08:10 VincentGillot

I have the same issue with 2 client component pages. Even when I change the page manually in the address bar, the same error occurs, mainly when trying to open the page second time.

I've found a workaround to continue my testing of Next.js 13. If I run dev with turbopack (next dev --turbopack), the error goes away. But it breaks client-side navigation with <Link> for unknown reason (it works like just <a>, doing a full page reload). Update: data fetching in client component pages breaks client-side navigation. If no data fetching is present, navigation by using turbopack works fine.

yura3d avatar Oct 26 '22 10:10 yura3d

I started a project from scratch with npx create next and the error appear either if the index page renders some "use client" or if 2 other pages have "use client". It does not fail if one subpage has "use client".

So basically;

index page with use client = fail 2+ subpages with use client = fail 1 subpage with use client = good

This is tested with all default files in the app/ folder and the pages are loading components from a components folder that has the use clients set.

image

VincentGillot avatar Oct 26 '22 11:10 VincentGillot

I have the same issue with 2 client component pages. Even when I change the page manually in the address bar, the same error occurs, mainly when trying to open the page second time.

I've found a workaround to continue my testing of Next.js 13. If I run dev with turbopack (next dev --turbopack), the error goes away. But it breaks client-side navigation with <Link> for unknown reason (it works like just <a>, doing a full page reload). Update: data fetching in client component pages breaks client-side navigation. If no data fetching is present, navigation by using turbopack works fine.

I can confirm --turbo removes the problem in my test case

VincentGillot avatar Oct 26 '22 11:10 VincentGillot

Rather interestingly, --turbo also seems to remove the errors for me in dev mode too.

They remain when trying to do next build though.

james-elicx avatar Oct 26 '22 11:10 james-elicx

They remain when trying to do next build though.

This is expected behavior since turbopack is used only in dev. So the issue is actual.

yura3d avatar Oct 26 '22 13:10 yura3d

I started a project from scratch with pnpm create next-app --ts --example with-turbo, this example uses the new client component format ('use client';.) And without making changes ran pnpm run build and it succeeded without errors. Following with pnpm run start, the app gets served. Haven't tried deploying to Vercel yet though.

muradbu avatar Oct 26 '22 14:10 muradbu

We talked about this issue in Next.js' Discord in the general chat. Seems like it works on Ubuntu using WSL2 🤔

image

muradbu avatar Oct 26 '22 14:10 muradbu

We talked about this issue in Next.js' Discord in the general chat. Seems like it works on Ubuntu using WSL2 🤔

Maybe OS problem?

I can build example project(https://github.com/moodiest/nextjs13-client-server-error-reproduction) on m1 macbook air, but it fails on windows 10.

build message on mac, success

m1

build message on windows 10, error

message
> next build

warn  - You have enabled experimental feature (appDir) in next.config.js.
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
info  - Thank you for testing `appDir` please leave your feedback at https://nextjs.link/app-feedback

info  - Creating an optimized production build
info  - Compiled successfully
info  - Linting and checking validity of types
info  - Collecting page data
[    ] info  - Generating static pages (0/6)TypeError: Cannot read properties of undefined (reading 'ClientComponent')
    at Oa (D:\nextjs13-client-server-error-reproduction\.next\server\chunks\235.js:1014:56)
    at Ia (D:\nextjs13-client-server-error-reproduction\.next\server\chunks\235.js:1127:50)
    at Array.toJSON (D:\nextjs13-client-server-error-reproduction\.next\server\chunks\235.js:904:32)
    at stringify (<anonymous>)
    at S (D:\nextjs13-client-server-error-reproduction\.next\server\chunks\235.js:1202:51)
    at Object.start (D:\nextjs13-client-server-error-reproduction\.next\server\chunks\235.js:1313:53)
    at g (D:\nextjs13-client-server-error-reproduction\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:102:35)
    at Object.start (D:\nextjs13-client-server-error-reproduction\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:1708:29)
    at Oe.n2 (D:\nextjs13-client-server-error-reproduction\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:770:39)
    at D:\nextjs13-client-server-error-reproduction\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:776:385
TypeError: Cannot read properties of undefined (reading 'default')
    at Oa (D:\nextjs13-client-server-error-reproduction\.next\server\chunks\235.js:1014:56)
    at Ia (D:\nextjs13-client-server-error-reproduction\.next\server\chunks\235.js:1127:50)
    at Array.toJSON (D:\nextjs13-client-server-error-reproduction\.next\server\chunks\235.js:904:32)
    at stringify (<anonymous>)
    at S (D:\nextjs13-client-server-error-reproduction\.next\server\chunks\235.js:1202:51)
    at Object.start (D:\nextjs13-client-server-error-reproduction\.next\server\chunks\235.js:1313:53)
    at g (D:\nextjs13-client-server-error-reproduction\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:102:35)
    at Object.start (D:\nextjs13-client-server-error-reproduction\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:1708:29)
    at Oe.n2 (D:\nextjs13-client-server-error-reproduction\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:770:39)
    at D:\nextjs13-client-server-error-reproduction\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.] {
  digest: '3120548961'
}
[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: '2368376545'
}

Error occurred prerendering page "/client-page". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: Cannot read properties of undefined (reading 'default')
    at Oa (D:\nextjs13-client-server-error-reproduction\.next\server\chunks\235.js:1014:56)
    at Ia (D:\nextjs13-client-server-error-reproduction\.next\server\chunks\235.js:1127:50)
    at Array.toJSON (D:\nextjs13-client-server-error-reproduction\.next\server\chunks\235.js:904:32)
    at stringify (<anonymous>)
    at S (D:\nextjs13-client-server-error-reproduction\.next\server\chunks\235.js:1202:51)
    at Object.start (D:\nextjs13-client-server-error-reproduction\.next\server\chunks\235.js:1313:53)
    at g (D:\nextjs13-client-server-error-reproduction\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:102:35)
    at Object.start (D:\nextjs13-client-server-error-reproduction\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:1708:29)
    at Oe.n2 (D:\nextjs13-client-server-error-reproduction\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:770:39)
    at D:\nextjs13-client-server-error-reproduction\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:776:385

Error occurred prerendering page "/server-page-with-client". Read more: https://nextjs.org/docs/messages/prerender-errorTypeError: Cannot read properties of undefined (reading 'ClientComponent')
    at Oa (D:\nextjs13-client-server-error-reproduction\.next\server\chunks\235.js:1014:56)
    at Ia (D:\nextjs13-client-server-error-reproduction\.next\server\chunks\235.js:1127:50)
    at Array.toJSON (D:\nextjs13-client-server-error-reproduction\.next\server\chunks\235.js:904:32)
    at stringify (<anonymous>)
    at S (D:\nextjs13-client-server-error-reproduction\.next\server\chunks\235.js:1202:51)
    at Object.start (D:\nextjs13-client-server-error-reproduction\.next\server\chunks\235.js:1313:53)
    at g (D:\nextjs13-client-server-error-reproduction\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:102:35)
    at Object.start (D:\nextjs13-client-server-error-reproduction\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:1708:29)
    at Oe.n2 (D:\nextjs13-client-server-error-reproduction\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:770:39)
    at D:\nextjs13-client-server-error-reproduction\node_modules\next\dist\compiled\@edge-runtime\primitives\streams.js:776:385
info  - Generating static pages (6/6)

> Build error occurred
Error: Export encountered errors on following paths:
        /client-page/page: /client-page
        /server-page-with-client/page: /server-page-with-client
    at D:\nextjs13-client-server-error-reproduction\node_modules\next\dist\export\index.js:405:19
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Span.traceAsyncFn (D:\nextjs13-client-server-error-reproduction\node_modules\next\dist\trace\trace.js:79:20)
    at async D:\nextjs13-client-server-error-reproduction\node_modules\next\dist\build\index.js:1263:21
    at async Span.traceAsyncFn (D:\nextjs13-client-server-error-reproduction\node_modules\next\dist\trace\trace.js:79:20)
    at async D:\nextjs13-client-server-error-reproduction\node_modules\next\dist\build\index.js:1123:17
    at async Span.traceAsyncFn (D:\nextjs13-client-server-error-reproduction\node_modules\next\dist\trace\trace.js:79:20)
    at async Object.build [as default] (D:\nextjs13-client-server-error-reproduction\node_modules\next\dist\build\index.js:64:29)

Can anyone test on different machines?

plastic041 avatar Oct 27 '22 02:10 plastic041

Maybe OS problem?

It's certainly seeming that way. My build on windows 10 failed completely but succeeded when I used Ubuntu through WSL2.

What I did find interesting though was that this appears to be a problem with webpack and Next.js 13, because using --turbo when running next dev --turbo works as expected, but when you remove the --turbo it starts to throw errors on page changes in development mode. Those errors are the same as the ones present when running build.

I imagine that when Turbopack supports building, this won't necessarily be as much of a problem, unless of course someone needs to be able to use webpack.

james-elicx avatar Oct 27 '22 07:10 james-elicx

I'm also getting an error on Windows 10 but only when navigating https://github.com/vercel/app-playground Builds and runs on WSL2 Debian but it's extremely slow

wait  - compiling /page (client and server)...
event - compiled client and server successfully in 9.4s (393 modules)
wait  - compiling...
event - compiled successfully in 392 ms (219 modules)
wait  - compiling /route-groups/(main)/page (client and server)...
wait  - compiling /layouts/page (client and server)...
wait  - compiling /loading/page (client and server)...
wait  - compiling /streaming/page (client and server)...
wait  - compiling /error-handling/page (client and server)...
wait  - compiling /ssg/page (client and server)...
event - compiled client and server successfully in 1140 ms (457 modules)
...

everdrone avatar Oct 27 '22 08:10 everdrone

I get the same problem on MacOS so it's not a Windows-specific problem.

log

yarn build
yarn run v1.22.18
warning ../../../package.json: No license field
$ next build
warn  - You have enabled experimental feature (appDir) in next.config.js.
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
info  - Thank you for testing `appDir` please leave your feedback at https://nextjs.link/app-feedback

info  - Creating an optimized production build  
info  - Compiled successfully
info  - Linting and checking validity of types  
info  - Collecting page data  
[    ] info  - Generating static pages (0/3)TypeError: Cannot read properties of undefined (reading '')
    at m (/Users/typeofweb/htdocs/saleor/test-13/node_modules/next/dist/compiled/react-server-dom-webpack/client.js:917:81)
    at Q (/Users/typeofweb/htdocs/saleor/test-13/node_modules/next/dist/compiled/react-server-dom-webpack/client.js:927:80)
    at S (/Users/typeofweb/htdocs/saleor/test-13/node_modules/next/dist/compiled/react-server-dom-webpack/client.js:928:317)
    at c (/Users/typeofweb/htdocs/saleor/test-13/node_modules/next/dist/compiled/react-server-dom-webpack/client.js:930:310)

Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: Cannot read properties of undefined (reading '')
    at m (/Users/typeofweb/htdocs/saleor/test-13/node_modules/next/dist/compiled/react-server-dom-webpack/client.js:917:81)
    at Q (/Users/typeofweb/htdocs/saleor/test-13/node_modules/next/dist/compiled/react-server-dom-webpack/client.js:927:80)
    at S (/Users/typeofweb/htdocs/saleor/test-13/node_modules/next/dist/compiled/react-server-dom-webpack/client.js:928:317)
    at c (/Users/typeofweb/htdocs/saleor/test-13/node_modules/next/dist/compiled/react-server-dom-webpack/client.js:930:310)

next info

    Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.1.0: Sun Oct  9 20:15:09 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T6000
    Binaries:
      Node: 18.10.0
      npm: 8.19.2
      Yarn: 1.22.18
      pnpm: 7.14.0
    Relevant packages:
      next: 13.0.1-canary.0
      eslint-config-next: 13.0.0
      react: 18.2.0
      react-dom: 18.2.0

typeofweb avatar Oct 27 '22 09:10 typeofweb

I've found out that in my case the error was caused by next/head component in a page.tsx file. When I removed it, the build succeeded.

typeofweb avatar Oct 27 '22 09:10 typeofweb

@mmiszy What happens when you run yarn build on https://github.com/moodiest/nextjs13-client-server-error-reproduction ?

plastic041 avatar Oct 27 '22 09:10 plastic041

I've found out that in my case the error was caused by next/head component in a page.tsx file. When I removed it, the build succeeded.

https://github.com/moodiest/nextjs13-client-server-error-reproduction has no next/head import, so it's not the problem.

plastic041 avatar Oct 27 '22 09:10 plastic041

I have the same problem but different error

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)

TheCodby avatar Oct 27 '22 11:10 TheCodby

also when I build the project I get this

TypeError: Cannot read properties of undefined (reading 'default')
    at Oa (C:\Ahmed\programming\apps\OurPlaces\ourplaces-beta\.next\server\chunks\418.js:2327:56)
    at Ia (C:\Ahmed\programming\apps\OurPlaces\ourplaces-beta\.next\server\chunks\418.js:2440:50)
    at Array.toJSON (C:\Ahmed\programming\apps\OurPlaces\ourplaces-beta\.next\server\chunks\418.js:2217:32)
    at stringify (<anonymous>)
    at S (C:\Ahmed\programming\apps\OurPlaces\ourplaces-beta\.next\server\chunks\418.js:2515:51)
    at Object.start (C:\Ahmed\programming\apps\OurPlaces\ourplaces-beta\.next\server\chunks\418.js:2626:53)
    at setupReadableByteStreamController (node:internal/webstreams/readablestream:3110:23)
    at setupReadableByteStreamControllerFromSource (node:internal/webstreams/readablestream:3147:3)
    at new ReadableStream (node:internal/webstreams/readablestream:245:7)
    at exports.renderToReadableStream (C:\Ahmed\programming\apps\OurPlaces\ourplaces-beta\.next\server\chunks\418.js:2623:24)
[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: '3366335327'
}

TheCodby avatar Oct 27 '22 20:10 TheCodby

I noticed when converted all client components and pages to server components (by deleting "use client") everything will work properly

TheCodby avatar Oct 28 '22 00:10 TheCodby

Ran into the same error while trying to run the Next13 Playground Demo App

Probably a hacky solution but got the app running as expected by doing the following :

  1. Change dev script to npm run dev --turbo
  2. It won't load the css since turbo doesn't support tailwindcss right away, more about it here.
  3. Created a file styles/main.css
  4. In app/layout.tsx, change the import '@/styles/global.css' to import '@/styles/main.css'
  5. Updated the dev script to concurrently \"next dev --turbo\" " \"tailwindcss --input styles/globals.css --output styles/main.css --watch\ and installed the required packages.
  6. npm run dev and it ran perfectly.

amarjeet987 avatar Oct 28 '22 04:10 amarjeet987

Ran into the same error while trying to run the Next13 Playground Demo App

Probably a hacky solution but got the app running as expected by doing the following :

  1. Change dev script to npm run dev --turbo
  2. It won't load the css since turbo doesn't support tailwindcss right away, more about it here.
  3. Created a file styles/main.css
  4. In app/layout.tsx, change the import '@/styles/global.css' to import '@/styles/main.css'
  5. Updated the dev script to concurrently \"next dev --turbo\" " \"tailwindcss --input styles/globals.css --output styles/main.css --watch\ and installed the required packages.
  6. npm run dev and it ran perfectly.

Yeah, I believe it is a webpack problem as using turbopack seems to function as expected. If you try building, you will most likely get the error again as the only option for building is webpack at the moment.

Would you be able to confirm which OS you are using?

james-elicx avatar Oct 28 '22 07:10 james-elicx

Ran into the same error while trying to run the Next13 Playground Demo App Probably a hacky solution but got the app running as expected by doing the following :

  1. Change dev script to npm run dev --turbo
  2. It won't load the css since turbo doesn't support tailwindcss right away, more about it here.
  3. Created a file styles/main.css
  4. In app/layout.tsx, change the import '@/styles/global.css' to import '@/styles/main.css'
  5. Updated the dev script to concurrently \"next dev --turbo\" " \"tailwindcss --input styles/globals.css --output styles/main.css --watch\ and installed the required packages.
  6. npm run dev and it ran perfectly.

Yeah, I believe it is a webpack problem as using turbopack seems to function as expected. If you try building, you will most likely get the error again as the only option for building is webpack at the moment.

Would you be able to confirm which OS you are using?

For this, windows 11

amarjeet987 avatar Oct 28 '22 07:10 amarjeet987

Get the same error. In my case I try to use a client component inside a server component, which results in this error. This should be possible right? Server component inside server component works fine, but i need a client component to use event handlers and hooks.

paviln avatar Oct 29 '22 00:10 paviln

Ran into the same error while trying to run the Next13 Playground Demo App

Probably a hacky solution but got the app running as expected by doing the following :

  1. Change dev script to npm run dev --turbo
  2. It won't load the css since turbo doesn't support tailwindcss right away, more about it here.
  3. Created a file styles/main.css
  4. In app/layout.tsx, change the import '@/styles/global.css' to import '@/styles/main.css'
  5. Updated the dev script to concurrently \"next dev --turbo\" " \"tailwindcss --input styles/globals.css --output styles/main.css --watch\ and installed the required packages.
  6. npm run dev and it ran perfectly.

Even if I got it working like this, I noticed that the loading feature doesn't work as expected with turbopack locally (it was behaving like it does with getServerSideProps). I had to create a new app, wrote some code to test it, got it running and ran it with webpack; and it was working as expected.

amarjeet987 avatar Oct 29 '22 09:10 amarjeet987

I've found out that in my case the error was caused by next/head component in a page.tsx file. When I removed it, the build succeeded.

This actually seemed to be the problem for me, using next/head causes build issues. The documentation currently uses the standard <head>...</head> in their code snippets so I assume this is a known issue?

trulysinclair avatar Oct 30 '22 04:10 trulysinclair

This change almost worked for me but I received an error about:

error - [rendering] [root of the dev server]/  Error during SSR Rendering
  Error: @next/font/google failed to run or is incorrectly configured.
  If you just installed `@next/font`, please try restarting `next dev` and resaving your file.

This issue happened whether or not I was using loading.tsx so I think theres an issue with Turbopack and next/font/google... Reference issue

Ran into the same error while trying to run the Next13 Playground Demo App

Probably a hacky solution but got the app running as expected by doing the following :

  1. Change dev script to npm run dev --turbo
  2. It won't load the css since turbo doesn't support tailwindcss right away, more about it here.
  3. Created a file styles/main.css
  4. In app/layout.tsx, change the import '@/styles/global.css' to import '@/styles/main.css'
  5. Updated the dev script to concurrently \"next dev --turbo\" " \"tailwindcss --input styles/globals.css --output styles/main.css --watch\ and installed the required packages.
  6. npm run dev and it ran perfectly.

chukwumaokere avatar Oct 31 '22 00:10 chukwumaokere

At first thought its below

I've found out that in my case the error was caused by next/head component in a page.tsx file. When I removed it, the build succeeded.

This actually seemed to be the problem for me, using next/head causes build issues. The documentation currently uses the standard

... in their code snippets so I assume this is a known issue?

but then the issue reoccurred after a while, so next/head seems unrelated or not the only culprit

schemburkar avatar Oct 31 '22 16:10 schemburkar

I ran in to the same issue. Build on Windows 11 failed completely. Failed occasionally in development mode too.

Build successfully on WSL 2, but very slow in development mode.

huaiyukhaw avatar Oct 31 '22 17:10 huaiyukhaw

Can confirm I am also running into this issue on Windows 10. There have been no confirmed fixes or genuine work arounds right? It's pretty breaking, preventing me from building anything using client components

amcd-dev avatar Oct 31 '22 21:10 amcd-dev

Can confirm I am also running into this issue on Windows 10. There have been no confirmed fixes or genuine work arounds right? It's pretty breaking, preventing me from building anything using client components

The only workarounds for Windows users appear to be using --turbo for dev mode or using a Linux distribution through something like WSL.

james-elicx avatar Oct 31 '22 23:10 james-elicx

I tried using --turbo but encountered a problem with @next/font/google so be mindful of that. https://github.com/vercel/next.js/issues/41841#issuecomment-1296379293

Windows subsystem linux or a dev machine (I use macOS now to run the dev environment and just remote in using VSCode) is the better solution OR turbo if you're NOT using @next/font/google for now.

chukwumaokere avatar Oct 31 '22 23:10 chukwumaokere