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.

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/kud/Projects/_kud/diary/node_modules/react-children-utilities/react-children-utilities.js
require() of ES modules is not supported.
require() of /Users/kud/Projects/_kud/diary/node_modules/react-children-utilities/react-children-utilities.js from /Users/kud/Projects/_kud/diary/.next/server/static/development/pages/_app.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 react-children-utilities.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/kud/Projects/_kud/diary/node_modules/react-children-utilities/package.json.

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1192:13)
    at Module.load (internal/modules/cjs/loader.js:1040:32)
    at Function.Module._load (internal/modules/cjs/loader.js:929:14)
    at Module.require (internal/modules/cjs/loader.js:1080:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.react-children-utilities (/Users/kud/Projects/_kud/diary/.next/server/static/development/pages/_app.js:1528:18)
    at __webpack_require__ (/Users/kud/Projects/_kud/diary/.next/server/static/development/pages/_app.js:23:31)
    at Module../src/lib/get-reading-time.js (/Users/kud/Projects/_kud/diary/.next/server/static/development/pages/_app.js:1017:82)
    at __webpack_require__ (/Users/kud/Projects/_kud/diary/.next/server/static/development/pages/_app.js:23:31)
    at Module../src/components/Layout/Post/index.js (/Users/kud/Projects/_kud/diary/.next/server/static/development/pages/_app.js:355:79)
    at __webpack_require__ (/Users/kud/Projects/_kud/diary/.next/server/static/development/pages/_app.js:23:31)
    at Module../src/pages/_app.js (/Users/kud/Projects/_kud/diary/.next/server/static/development/pages/_app.js:1075:82)
    at __webpack_require__ (/Users/kud/Projects/_kud/diary/.next/server/static/development/pages/_app.js:23:31)
    at Object.0 (/Users/kud/Projects/_kud/diary/.next/server/static/development/pages/_app.js:1395:18)
    at __webpack_require__ (/Users/kud/Projects/_kud/diary/.next/server/static/development/pages/_app.js:23:31)
    at /Users/kud/Projects/_kud/diary/.next/server/static/development/pages/_app.js:91:18 {
  code: 'ERR_REQUIRE_ESM'
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:21 (10 by maintainers)

github_iconTop GitHub Comments

6reactions
revskill10commented, Jun 5, 2020

Hi, you can use next-transpile-modules .

const withTM = require('next-transpile-modules')(['react-children-utilities']);
1reaction
hazem3500commented, Dec 17, 2020

I couldn’t get it to work with next.js even with the solution above but it turns out I misunderstood the solution above, my bad 😅

Read more comments on GitHub >

github_iconTop Results From Across the Web

Wes Bos on Twitter: "Anyone using the esm package with ...
I've rolled back gatsby, esm and node and it still has the issue ... Ah, yes, my patch might have broken this 😬...
Read more >
MR - Reply to a comment doesn't show the editor (#273005) · Issues ...
When replying to an MR comment, the text filed disappear. Steps to reproduce. We don't have proper steps to reproduce. This happens with...
Read more >
Jon C.'s Post - LinkedIn
Why should #ITSM and #ESM Leaders consider IFS assyst? ... What's easy: 'That's not in my job description' 😬 What's hard: Taking on...
Read more >
emoji-emotion - NPM Package Overview - Socket.dev
import {emojiEmotion} from 'https://esm.sh/emoji-emotion@3' ... Socket installs a Github app to automatically flag issues on every pull ...
Read more >
Module Constraints - Remix
So what's the problem? ... db"; //😬 console.log(prisma); //🥶 export function meta() { return { title: "Posts" }; } export default function Posts()...
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