Preact: Can't resolve 'react/jsx-runtime.js'
See original GitHub issueCongratulations on the upgrade to MDX 2! I’m excited to try it. Unfortunately I got this error when rendering some MDX with next-mdx-remote 4.0.0, Next 12.1.0, and Preact 10.6.6:
error - ./node_modules/next-mdx-remote/dist/index.js:2:0
Module not found: Can't resolve 'react/jsx-runtime.js'
Import trace for requested module:
./node_modules/next-mdx-remote/index.js
./components/pages/StaticPage.tsx
./pages/[slug].tsx
Removing the .js
from this line in dist/index.js
(and presumably src/index.tsx
) seems to fix it:
import * as runtime from 'react/jsx-runtime.js';
But now I’m getting a different error:
TypeError: Cannot read properties of undefined (reading '__H')
This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
m
file:/Users/eostrom/workspace/swagleft/next-swagleft/node_modules/preact/hooks/dist/hooks.mjs (1:151)
p
file:/Users/eostrom/workspace/swagleft/next-swagleft/node_modules/preact/hooks/dist/hooks.mjs (1:280)
l
file:/Users/eostrom/workspace/swagleft/next-swagleft/node_modules/preact/hooks/dist/hooks.mjs (1:249)
Object.MDXRemote
file:/Users/eostrom/workspace/swagleft/next-swagleft/node_modules/next-mdx-remote/dist/index.js (31:51)
That line doesn’t look like it should cause any problems:
const [isReadyToRender, setIsReadyToRender] = useState(!lazy || typeof window === 'undefined');
I’ll try to come back to it later and debug, submit a PR, or provide a minimal test case, but I thought I’d place a marker here in the meanwhile, in case anyone else is running into the same problem – or, in case it’s working just fine for everyone else and the problem is I’ve misconfigured something.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top Results From Across the Web
got Can't resolve 'react/jsx-runtime' error while use try to create ...
To solve the error "Module not found: Error: Can't resolve 'react/jsx-runtime'", make sure to update the react package by opening your ...
Read more >react-dnd 16.0.0 is causing "Module not found: Error: Can't ...
This is due to React 17 not having the correct exports entries in package.json . React 18 has those entries, so it should...
Read more >unable to resolve "react/jsx-runtime" from "app.js" - You.com
js file in root project folder by following. It seems that the current versions of Meteor and the React npm package do not...
Read more >Can't resolve 'react/jsx-runtime' in 'C:\Users\qurek\Desktop\tmp ...
I have decided to add Material UI to my old React project (I use pure JavaScript). When I try to run application the...
Read more >Compiling legacy components in Next.js (Can't resolve 'react ...
It seems like, based on the current documentation, (I'm more of a Node.js user) you can use @babel/plugin-transform-react-jsx or @babel/preset-react , or you ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just thought I’d pop in as I’m having issues with the
jsx-runtime.js
file after enabling the experimental Suspense implementation in Next.js 12.1.0.Very similar build error:
This temporary
next.config.js
fix worked for me w/ React 18 (I think what @fernpolo was also running into), so I assume this would help with the same Preact roadblock?See Next.js documentation on adding webpack aliases here or the fix in my repo. 😃