Skip to content

Cannot find module 'react/jsx-runtime' when using "module": "nodenext" #47804

Closed
@AndrewLeedham

Description

@AndrewLeedham

Bug Report

The experimental "module": "nodenext" ESM support does not work with "jsx": "react-jsx". Causing the following error:

Cannot find module 'react/jsx-runtime' or its corresponding type declarations.

🔎 Search Terms

esm,module,nodenext,jsx,react/jsx-runtime

🕗 Version & Regression Information

  • This only occurs in nightly builds.
  • I was unable to test this on prior versions because nodenext is only supported in the nightly versions.

⏯ Playground Link

Playground link with relevant code

💻 Code

Any JSX code would cause the error, this is what I used:

export default function Hello() {
    return <h1>Hello World</h1>;
}

🙁 Actual behavior

"jsx": "react-jsx" does not work with experimental ESM support ("module": "node-next").

🙂 Expected behavior

Expectation was for react-jsx to work going forward with ESM, but it cannot find react/jsx-runtime because it does not have the .js extension and/or React@17 does not have "exports": { "./jsx-runtime": "./jsx-runtime.js" } or similar in it's package.json. It looks like React@18 will add the aforementioned exports field, so I am wondering if either .js would be added when using node-next or if React@18 is a blocker for TS ESM support?

Metadata

Metadata

Assignees

Labels

ExternalRelates to another program, environment, or user action which we cannot control.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions