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

Using react-markdown with Next.js 15 app dir results in error #869

Closed
4 tasks done
steebchen opened this issue Oct 26, 2024 · 4 comments
Closed
4 tasks done

Using react-markdown with Next.js 15 app dir results in error #869

steebchen opened this issue Oct 26, 2024 · 4 comments
Labels
👀 no/external This makes more sense somewhere else 👎 phase/no Post cannot or will not be acted on

Comments

@steebchen
Copy link

steebchen commented Oct 26, 2024

Initial checklist

Affected packages and versions

9.0.1

Link to runnable example

No response

Steps to reproduce

Use Next.js >=15.0.0 and render <Markdown>...</Markdown> in a server component.

NOTE: adding use client in the component which renders Markdown fixes the build, however any route will always return 500 even though it still renders fine.

Expected behavior

No error. It works fine in Next 14.

Actual behavior

Error: Failed to collect configuration for /product/[id]/[slug]
    at /Users/a/b/c/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/build/utils.js:1130:23
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Span.traceAsyncFn (/Users/a/b/c/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/trace/trace.js:157:20) {
  [cause]: ReferenceError: document is not defined
      at 29265 (/Users/a/b/c/.next/server/edge-chunks/829.js:1:52366)
      at t (/Users/a/b/c/.next/server/edge-runtime-webpack.js:1:485)
      at 78130 (/Users/a/b/c/.next/server/app/product/[id]/[slug]/page.js:1:28452)
      at t (/Users/a/b/c/.next/server/edge-runtime-webpack.js:1:485)
      at 27165 (/Users/a/b/c/.next/server/app/product/[id]/[slug]/page.js:1:3661)
      at Function.t (/Users/a/b/c/.next/server/edge-runtime-webpack.js:1:485)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
}

> Build error occurred
Error: Failed to collect page data for /product/[id]/[slug]
    at /Users/a/b/c/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/build/utils.js:1233:15
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  type: 'Error'
}
 ELIFECYCLE  Command failed with exit code 1.

Affected runtime and version

node v20

Affected package manager and version

pnpm v9.12.0

Affected OS and version

macos

Build and bundle tools

Next.js

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Oct 26, 2024
@ChristianMurphy
Copy link
Member

Welcome @steebchen! 👋
Sorry you ran into a spot of trouble.

This project doesn't use document https://github.com/search?q=repo%3Aremarkjs%2Freact-markdown+document&type=code

The error is coming from somewhere else.
My guess is that next.js isn't correctly resolving exports for a dependency somewhere and chose the browser version instead of the server version.

@steebchen
Copy link
Author

steebchen commented Oct 26, 2024

Hey thanks for the quick reply. Hmm it's super weird. I can basically comment this out and it works fine:

IntelliJ IDEA 2024-10-26 22 53 11 IntelliJ IDEA 2024-10-26 22 53 26

It is the same when my markdown content is just foo or something.

Any idea how I could figure out how an other dependency might be related?

@wooorm
Copy link
Member

wooorm commented Oct 28, 2024

Closing as you indicate this is related to a very new Next 15; not Next 14; I haven’t seen this outside of Next. The problem and the fix are probably in Next 15. Not here.

Issues are for issues. General debugging help can go in other places.

I would recommend asking the multi-million dollar company for help with their new tools that do complex resolving things, which sounds like where the bug is.

@wooorm wooorm closed this as not planned Won't fix, can't repro, duplicate, stale Oct 28, 2024
@wooorm wooorm added the 👀 no/external This makes more sense somewhere else label Oct 28, 2024

This comment has been minimized.

@github-actions github-actions bot added 👎 phase/no Post cannot or will not be acted on and removed 🤞 phase/open Post is being triaged manually labels Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👀 no/external This makes more sense somewhere else 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

3 participants