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.

Dependency Iconify v.1.2 breaks build - Error [ERR_REQUIRE_ESM]: Must use import to load ES Module

See original GitHub issue

It seems the iconify package version 1.2 breaks our build when using this package. It stopped working over the weekend and we were unable to build it with next build. We used this packaged for about a year without any problems. We tried switching node versions, versions of this package and a lot of other related packages but the it seems the culprit was the @iconify/icons-mdi : version “1.2.0”. When we forced this package to use an older version, 1.1.37 in our case, everything worked as it should. Don’t know if this is a bug or a special case only applicable to our environment. But i’ll put it here anyway if someone else is having the same issue. Don’t really know if this is the best solution either, but it solved our issue

Add this in your package.json (we are using yarn, dont know how this will work with npm)

 "resolutions": {  
    "react-h5-audio-player/@iconify/icons-mdi": "1.1.37"
  }


> Build error occurred
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/ubuntu/frontend/node_modules/@iconify/icons-mdi/play-circle.js
require() of ES modules is not supported.
require() of /home/ubuntu/frontend/node_modules/@iconify/icons-mdi/play-circle.js from /home/ubuntu/frontend/node_modules/node_modules/react-h5-audio-player/lib/index.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 play-circle.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/ubuntu/frontend/node_modules/@iconify/icons-mdi/package.json.

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1089:13)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/home/ubuntu/frontend/node_modules/react-h5-audio-player/lib/index.js:36:42)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.23v/ (/home/ubuntu/tfrontend/.next/server/pages/_app.js:1273:18)
    at __webpack_require__ (/home/ubuntu/frontend/.next/server/pages/_app.js:29:31)
    at Module.1TCz (/home/ubuntu/frontend/.next/server/pages/_app.js:793:39)
    at __webpack_require__ (/home/ubuntu/frontend/.next/server/pages/_app.js:29:31) {
  code: 'ERR_REQUIRE_ESM'
}

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
theDanielJLewiscommented, Mar 19, 2022

You’re right. It was actually probably because I was still on Webpack 4.x. After I was able to upgrade to 5.x, I could update to 3.8.3.

0reactions
mrgansercommented, Apr 5, 2022

Yup, in any case, just for the record, it seems they published a new version for avoid crashing projects with old tooling: https://github.com/iconify/iconify/issues/126#issuecomment-1084476654

Read more comments on GitHub >

github_iconTop Results From Across the Web

Must use import to load ES Module / require() of ES ... - GitHub
I have suddenly started getting the following error: $ npm test > geodesy@2.2.0 test /home/travis/build/chrisveness/geodesy > mocha --exit ...
Read more >
ESLint - Error: Must use import to load ES Module
go to .eslintrc.js and make sure you have the following settings: module.exports = { parser: " ...
Read more >
Error ERR REQUIRE ESM | Must use import to load ES Module
Your browser can't play this video. Learn more. Switch camera.
Read more >
Error [ERR_REQUIRE_ESM]: Must use import to load ES ...
When starting node-red I am getting following error in log file: Welcome to ... Error [ERR_REQUIRE_ESM]: Must use import to load ES Module....
Read more >
Iconify Updates
All icon components updated 29 Nov 2022. All icon components have been updated! This release fixes a bug in icon loading function, which...
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