ERR_REQUIRE_ESM with Node 18.2
See original GitHub issueBug Report
Description
Log4brains init does’nt work and produce following error with node 18.2 clean install.
/usr/local/lib/node_modules/log4brains/node_modules/esm/esm.js:1
const __global__ =
.../... (long source code)
/usr/local/lib/node_modules/log4brains/node_modules/@log4brains/core/dist/index.module.js:1
Error [ERR_REQUIRE_ESM]: require() of ES Module /usr/local/lib/node_modules/log4brains/node_modules/cheerio/lib/esm/index.js not supported.
Instead change the require of index.js in null to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/usr/local/lib/node_modules/log4brains/node_modules/@log4brains/core/dist/index.module.js:1)
at Generator.next (<anonymous>)
at Object.<anonymous> (/usr/local/lib/node_modules/log4brains/node_modules/@log4brains/cli/dist/cli.js:1)
at Generator.next (<anonymous>)
at Object.<anonymous> (/usr/local/lib/node_modules/log4brains/node_modules/@log4brains/cli/dist/index.js:1)
at Generator.next (<anonymous>)
at Object.<anonymous> (/usr/local/lib/node_modules/log4brains/dist/cli.js:1)
at Generator.next (<anonymous>)
at Object.<anonymous> (/usr/local/lib/node_modules/log4brains/dist/main.js:1)
at Generator.next (<anonymous>)
at Object.<anonymous> (/usr/local/lib/node_modules/log4brains/dist/log4brains:5:18) {
code: 'ERR_REQUIRE_ESM'
Steps to Reproduce
- npm y -g log4brains
- log4brains init
Expected Behavior
Log4brains should work as expecte…
Context
Simply trying to init log4brains
Environment
- Log4brains version: 1.0.0-beta.11
- Node.js version: v18.2.0
- OS and its version: MacOS X
- Browser information: NA
npm -g list
/usr/local/lib
├── log4brains@1.0.0-beta.11
└── npm@8.9.0
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:5 (1 by maintainers)
Top 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 >ES modules not supported · Issue #1291 · vercel/pkg - GitHub
I'm getting the following error as soon as the compiled app boots: node:internal/modules/cjs/loader:930 throw err; ^ Error: Cannot find module ...
Read more >node-fetch Error [ERR_REQUIRE_ESM]: require() of ES ...
The node-fetch error "[ERR_REQUIRE_ESM]: require() of ES Module not supported" occurs because the node-fetch package has been converted to be an ESM-only ...
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 ... nodered/node-red:1.1.2-12 (= Node.js version: v12.18.2) ...
Read more >Download & Update Node.js to the Latest Version! Node v19 ...
Direct download links to update to the latest Node.js versions: Node v19.0.0 / LTS ... src: print source map error source on demand...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
A possible workaround: Manually downgrade cheerio to 1.0.0-rc.10 works.
I used yarn and the following package.json
Hi!
Fixed in v1.0.0-beta.12 by pinning a fixed version of cheerio directly in the project, as suggested in your workaround ; thank you for this!
Also, to avoid similar incidents in the future, I created this proposal: https://github.com/thomvaill/log4brains/issues/77 I will try to work on this soon