question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CJS build incompatible with react-dnd v16

See original GitHub issue

The latest release of react-dnd is now only published as an ECMAScript module. See here: https://github.com/react-dnd/react-dnd/releases/tag/v16.0.0

This ends up breaking react-dnd-preview’s CommonJS distribution (dist/cjs folder) with an error like this:

Error: Must use import to load ES Module: /node_modules/react-dnd/dist/index.js
require() of ES modules is not supported.
require() of /node_modules/react-dnd/dist/index.js from /node_modules/react-dnd-preview/dist/cjs/usePreview.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /node_modules/react-dnd/package.json.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:7
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
carlos-movembercommented, Sep 29, 2022

first, thanks a lot for this great library 😃

is this next branch going to be merged to main for a new version? I’m using dnd with this library in a project that recently got switched to nextjs and it’s failing to compile due to the Common JS module, or could version be added to the package.json file so that a specific branch can be installed with yarn? I could create a PR for it if needed

1reaction
TCheruycommented, Dec 12, 2022

@LouisBrunner Yep, it’s working for me, thanks for your work !

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-dnd, not compatible with older version of react or react ...
I am checking things. Now I am not certain the jenkins pipeline which runs the build is actually using React version 16.14.0 but...
Read more >
React DnD
React DnD is a set of React utilities to help you build complex drag and drop interfaces while keeping your components decoupled. It...
Read more >
react-beautiful-dnd inconsistent drop zone width
When dragging with a mouse the impact of an item is based on it's center position. So the center position of an item...
Read more >
yarn installation issues - Google Groups
1.2.9: The platform "linux" is incompatible with this module. ... react-dnd-test-backend has no build:canvas script, skipping missing
Read more >
React v16.0 – React Blog
We're excited to announce the release of React v16.0! Among the changes are some ... render() { // React does *not* create a...
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