Module not found: Error: Package path ./jsx-runtime.js is not exported from package react.

See original GitHub issue

Describe the bug After upgrading to React 18, react-dnd is now breaking. I am running react-dnd@15.1.2 and I am getting this error:

Module not found: Error: Package path ./jsx-runtime.js is not exported from package ../node_modules/react (see exports field in ../node_modules/react/package.json)

I see that this issue is fixed in react-dnd@16 however, I cannot upgrade to this version, as the ESM only support breaks my test runs.

In issue #3423 where people experience the opposite problem (they have upgraded to v16, and are still on react 17) there is posted a suggestion to add a resolve.fallback to webpack config. I am currently running on create-react-app, and really would not like to eject for such a simple issue.

Related issues #3428

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:22
  • Comments:7

github_iconTop GitHub Comments

7reactions
mikaelrsscommented, Apr 26, 2022

For anyone who are using create-react-app and does not want to eject, this solution worked for me:

I used react-app-rewired with this config-overrides.js:

module.exports = {
  webpack: function (config) {
    return {
      ...config,
      resolve: {
        ...config.resolve,
        alias: {
          "react/jsx-runtime.js": "react/jsx-runtime",
          "react/jsx-dev-runtime.js": "react/jsx-dev-runtime"
        }
      }
    };
  }
};

I don’t think this is an ideal solution, but if you want to upgrade to React 18, and still be on react-dnd@15, I cannot see another solution.

5reactions
edcuidevcommented, Apr 22, 2022

I am also getting same error.

ERROR in ./node_modules/react-dnd/dist/core/DndProvider.js 37:0-48
Module not found: Error: Can't resolve 'react/jsx-runtime' in 'node_modules\react-dnd\dist\core'
Did you mean 'jsx-runtime.js'?
BREAKING CHANGE: The request 'react/jsx-runtime' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
.......

project is based on create-react-app and these are in package.json.

    "react": "^17.0.2",
    "react-dnd": "^16.0.1",
    "react-dnd-html5-backend": "^16.0.1",

any thoughts?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module not found: Error: Package path . is not exported from ...
The issue for me ended up being image imports in the js file. I had these mock valus: import Course1 from "../../ui/course-1.png"; ...
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 >
module not found: error: package path . is not ... - You.com
The issue in your code is that you are using functions that are never imported from React. To resolve this issue, you need...
Read more >
Package exports - webpack
Any other requests will lead to a ModuleNotFound Error. ... When not using the abbreviation, direct file access e. g. package/file.js will not...
Read more >
How to Build Your Own Blog with Next.js and MDX
What to do if you get a server error. Error: Package subpath "./jsx-runtime.js" is not defined by "exports" in "path-to-node_modules/ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found