react-page: jsx-runtime not exported (DndProvider error)
Hi, I want to try reactpage but when npm run dev, i have error :
error - ./node_modules/react-dnd/dist/esm/core/DndProvider.mjs:28:0
Module not found: Package path ./jsx-runtime.js is not exported from package /home/raphael/Documents/nextjs/rnd-text-editor-nextjs/node_modules/react (see exports field in /home/raphael/Documents/nextjs/rnd-text-editor-nextjs/node_modules/react/package.json)
I use : boilerplate nextjs + typescript
package.json :
index.tsx :
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 34 (1 by maintainers)
Sorry for the late response. Updating to 13.1.2 fixed the issue momentarily, but we since upgraded to next 13.4.5 and the issue reappeared, but I’ve since been able to fix the issue.
To fix use react-dnd with ESM support we need to upgrade the version react-page is using internally to ^16. In our pnpm repo, this can be achieved by adding the following to the package.json:
We then get the following error when trying to build using Next:
This means we need to update all imports in the react-page package to use
import()
instead ofrequire()
. To do this with pnpm. We can use the patch command like this:pnpm patch @react-page/editor
. Open the folder and use the search & replace functionality of your IDE to change all imports of react-dnd like this:After that run
pnpm patch-commit <PATCH_FOLDER>
to apply the patch.I hope this is helpful for people using Next.js! If this a generally appliable patch for all bundlers, I would be happy to create a PR to finally fix this, but I’m not sure if this just works for Next.js.
@634750802 hi, i found the problem, https://github.com/react-page/react-page/issues/1281
@macrozone i have just created a demo repo and a preview on codespace, the issue was reproduced.
my local node is v18.12.1, npm is 8.19.2
please use react 17 at the moment.
see also https://github.com/react-dnd/react-dnd/issues/3416