question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error with package path jsx-runtime updating Nextjs with React 18

See original GitHub issue

I tried updating my website with React 18 (Nextjs v12.1.2) and not compiling. The error is:

wait  - compiling...
error - ./node_modules/next-contentlayer/dist/hooks/useMDXComponent.js:5:0
Module not found: Package path ./jsx-runtime.js is not exported from package /.../me/nikosantis.dev/node_modules/react (see exports field in /.../me/nikosantis.dev/node_modules/react/package.json)

Import trace for requested module:
./node_modules/next-contentlayer/dist/hooks/index.js
./pages/sobre-mi.tsx

https://nextjs.org/docs/messages/module-not-found

I tested changing the jsx_runtime import in useMDXComponent in node_modules and compiled again.

from:

import * as _jsx_runtime from 'react/jsx-runtime.js'

to:

import * as _jsx_runtime from 'react/jsx-runtime'

Working with this change without errors 😎 idk why… I tried this change in the contentlayer repo (feat/0.2.0 branch), yarn build and yarn test and all tests passed 💯 Can you check that?

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
dvldencommented, Apr 1, 2022

Anyone else still having troubles with it, after updating to latest release? I upgraded Next, React and Content Layer (all to latest), fixed the Next config file and I still get the same error.

Module not found: Package path ./jsx-runtime.js is not exported from package /Users/nn/Sites/dvl-next/node_modules/.pnpm/next-contentlayer@0.2.1_c0abbb53577d424fe320649841fdc7d4/node_modules/react (see exports field in /Users/nn/Sites/dvl-next/node_modules/.pnpm/next-contentlayer@0.2.1_c0abbb53577d424fe320649841fdc7d4/node_modules/react/package.json)
3reactions
schicklingcommented, Mar 30, 2022

Update: I think I found a “solution” aka functioning work-around for this problem:

image

Will be released with the upcoming 0.2.0 release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues - GitHub
I am running react-dnd@15.1.2 and I am getting this error: Module not found: Error: Package path ./jsx-runtime.js is not exported from ...
Read more >
got Can't resolve 'react/jsx-runtime' error while use try to create ...
Updating your react version possibily can resolve your problem. Command line: npm install --save react@latest.
Read more >
React 18: Switchable Runtime - Next.js
Learn more about the switchable runtimes (Edge and Node.js) in Next.js. ... Next.js has two server runtimes where you can render parts of...
Read more >
Module not found: Can't resolve 'react/jsx-runtime' | bobbyhadz
To solve the error "Module not found: Error: Can't resolve 'react/jsx-runtime'", make sure to update the react package by opening your terminal in...
Read more >
react-dnd 16.0.0 and DnDProvider.js : r/reactjs - Reddit
js '? BREAKING CHANGE: The request 'react/jsx-runtime' failed to resolve only because it was resolved as fully specified (probably because the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found