Cannot find module `.../jsx-runtime`
See original GitHub issueDescribe the bug
I have a library that depends on another library. Both using vite to build with react@17, TypeScript, pnpm, and in ESM.
The build works fine, but vitest failed with:
Error: Cannot find module 'D:\code\justland\just-web-react\libraries\react\node_modules\react\jsx-runtime' imported from D:\code\justland\just-web-react\libraries\react\dist\just-web-react.js
Did you mean to import react/node_modules/.pnpm/react@17.0.2/node_modules/react/jsx-runtime.js?
Reproduction
Since it involves one library referencing another, it will take some effort to come up with a minimal repro.
For the time being, here is the code:
- https://github.com/justland/just-web-react
git checkout jsx-runtime-errorpnpm installpnpm buildpnpm commands test
System Info
System:
OS: Windows 10 10.0.22621
CPU: (16) x64 AMD Ryzen 7 5800X 8-Core Processor
Memory: 31.94 GB / 63.92 GB
Binaries:
Node: 14.20.0 - C:\Program Files\nodejs\node.EXE
npm: 6.14.17 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.22621.819.0), Chromium (108.0.1462.42)
Internet Explorer: 11.0.22621.1
Used Package Manager
pnpm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created 9 months ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Uncaught Error: Cannot find module 'react/jsx-runtime'
This solution resolved my issue. I found it over here. 👇️ with NPM. npm install react@latest react-dom@latest ...
Read more >Cannot find module 'react/jsx-runtime' · Issue #2119 - GitHub
It means that it doesn't find react/jsx-runtime module as if you would have an older version installed. Please always try to share a...
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 >cannot find module '@emotion/react/jsx-runtime' or its ...
If you're still getting the "Cannot find module 'react/jsx-runtime' or its corresponding type declarations" error, open your package.json file and make sure ......
Read more >[Solved]-Uncaught Error: Cannot find module 'react/jsx-runtime'
[Solved]-Uncaught Error: Cannot find module 'react/jsx-runtime'-Reactjs ... So my setup actually was working. There was somehow a glitch in the symlink. I as...
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
Your files need to be processed by Vitest (they are externalised in your case). Add this to your
vite.config.ts:I was also able to fix the issue by adding
.jsextension to import, sincejsx-runtimeis not specified in react’sexportsfield (otherwise, it’s required by ESM spec). This would actually be faster than inlining dependency.Have a look at this issue and it’ll never be fixed for react 16 and 17 https://github.com/facebook/react/issues/20235