Error [ERR_REQUIRE_ESM]: require() of ES Module

See original GitHub issue

Versions

- slice-machine-ui: 0.3.3
- @nuxtjs/prismic: "alpha",

Reproduction

Add both dependencies as devDependencies and run npm/yarn run slicemachine, will yield the following error:

/node_modules/@slicemachine/core/build/src/utils/cliLogs.js:8
const ora_1 = __importDefault(require("ora"));
                              ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /node_modules/ora/index.js 
from /node_modules/@slicemachine/core/build/src/utils/cliLogs.js not supported.
Instead change the require of index.js in /node_modules/@slicemachine/core/build/src/utils/cliLogs.js 
to a dynamic import() which is available in all CommonJS modules.

Proposed solution

Use import instead of require.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:5
  • Comments:7

github_iconTop GitHub Comments

3reactions
jeremytenjocommented, May 5, 2022

Current dirty solution is to install node-fetch v2.6.1 - npm i node-fetch@2.6.1

0reactions
drewhayescommented, May 18, 2022

I was having the same issue. The solution from @jeremytenjo to install v2.6.1 worked for me.

(Using a next.js project–so the error isn’t nuxt specific)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error [ERR_REQUIRE_ESM]: require() of ES Module not ...
The node-fetch latest version doesn't use the require() syntax to import the package. You need to go to your package.json and type
Read more >
Error [ERR_REQUIRE_ESM]: require() of ES Module not ...
The error [ERR_REQUIRE_ESM]: require() of ES Module not supported. Instead change the require of index.js to a dynamic import() which is available in...
Read more >
require() of ES Module fix-path/index.js from main.ts ... - GitHub
App threw an error during load Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/manuel/src/electron-react-boilerplate/node_modules/fix-path/index.js ...
Read more >
Error [ERR_REQUIRE_ESM]: require() of ES Module - Support
Error [ERR_REQUIRE_ESM]: require() of ES Module when trying to compile a typescript service implementing the netlify api module. Version 11.0.1.
Read more >
ERR_REQUIRE_ESM - DEV Community ‍ ‍
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: ~/projects/semantic-release-toolkit/node_modules/zz/cjs.js require() of ES ...
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