Skip to content

[Bug]: Cannot find module 'node_modules/react/jsx-runtime #1319

Open

Description

@MatthewCallis

Would you like to work on a fix?

  • Check this if you would like to implement a PR, we are more than happy to help you go through the process.

Current and expected behavior

While testing the v5.3.1 update I started getting test failures I was not getting in v5.3.0 with vite & vitest. Downgraded just to confirm and reapplied the update and get the following error:

Error: Cannot find module 'node_modules/react/jsx-runtime' imported from node_modules/react-chartjs-2/dist/index.js
Did you mean to import "react/jsx-runtime.js"?
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { code: 'ERR_MODULE_NOT_FOUND', url: 'file:///node_modules/react/jsx-runtime' }

Reproduction

Trying to use a Bar chart in a component in a test

chart.js version

v4.5.1

react-chartjs-2 version

v5.3.1

Possible solution

It seems like #1309 is the underlying change

Activity

  1. mightyvoid commented on Oct 28, 2025

    @mightyvoid

    same issue, this change broke our deployment pipeline,
    React 17 with v5.3.1.

  2. dangreen commented on Nov 5, 2025

    @dangreen
    Collaborator

    @MatthewCallis @mightyvoid Hi. Could you please provide repo with reproduction? Cause all sandboxes are working without issue like that

  3. self-assigned this
    on Nov 5, 2025
  4. MatthewCallis commented on Nov 5, 2025

    @MatthewCallis
    Author

    @dangreen I'll try and get a repro, but I see in the sandboxes there is no matrix testing of React versions, everything is at v19 in the sandbox. Due to other dependencies I am stuck at v17, but would not have expected a semver breaking change on a point update.

  5. dangreen commented on Nov 5, 2025

    @dangreen
    Collaborator
  6. dangreen commented on Nov 5, 2025

    @dangreen
    Collaborator

    Your issue look like bundler misconfiguration.

    react@17 have 'jsx-runtime' file: https://app.unpkg.com/react@17.0.2/files/jsx-runtime.js

    react@17 package.json don't have 'exports' field: https://app.unpkg.com/react@17.0.2/files/package.json

    Thus bundler should resolve 'react/jsx-runtime' to 'node_modules/react/jsx-runtime.js' (like nodejs do, you can test it)

  7. davidminor commented on Dec 9, 2025

    @davidminor

    I had the same issue, resolved it using this config suggestion: xyflow/xyflow#4683 (comment)

    (We're using craco which is how I was able to modify the webpack config)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions