emotion: Cannot find module 'react/jsx-runtime'
Current behavior:
I’ve upgraded to v11, I received the following error when the run the test suite.
● Test suite failed to run
Cannot find module 'react/jsx-runtime' from 'node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.cjs.dev.js'
Require stack:
node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.cjs.dev.js
node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.cjs.js
packages/react-ui/src/utils/test-utils.js
jest.setup.js
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:306:11)
at Object.<anonymous> (node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.cjs.dev.js:14:23)
My babel file:
module.exports = {
env: {
test: {
presets: [
[
"@babel/preset-env",
{
targets: {
node: "current",
},
},
],
[
"@babel/preset-react",
{
runtime: "automatic",
importSource: "@emotion/react",
},
],
],
plugins: ["@emotion/babel-plugin"],
},
},
};
Environment information:
reactversion: 17.0.1@emotion/reactversion: 11.0.0@emotion/jestversion: 11.1.0@emotion/babel-pluginversion: 11.0.0
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 22 (2 by maintainers)
As of now, this fixes it for me…
yarn add @types/reactor
npm install @types/reactI generated a new
lockfile and works fine, thanks for the help!Looks like certain versions of Emotion aren’t compatible with certain versions of React. In this particular case, I had to upgrade
reactandreact-domfrom16.13.1to17.0.1for Emotion 11 to successfully pass unit tests in one project.I’m investigating and this looks like a problem with
yarnto resolve the dependencies, when I try to runnpm installthis works fine, but withyarnnot.@mverissimo Thanks for reply. Issue is resolved now, I locked my dependency versions so removing node_modules and package-lock.json didn’t worked for me 😅.
So I updated my react and react-script version and issue is resolved.
Thanks 🤩.
I’m still waiting for someone to answer this
how do you solve this problem in codesandbox.io.
this is still an issue with yarn 2 + workspaces + pnp. same with
/styled/basenot found.Cannot find module ‘react/jsx-runtime’ from ‘Accordion.js’
I’m facing same issue, I removed node_modules and package-lock.json and run npm i. still getting “Cannot find module ‘react/jsx-runtime’ from ‘Accordion.js’” error.
Any idea ?
Upgraded everything to React 17 and Emotion 11. Took quite a while to get it done since some projects used Enzyme, and we had to update that too.
I’ve never gotten a project with Emotion 10 to run side-by-side with Emotion 11 even from transpiling it in the bundle.