I'm using log-update and I recently upgraded to version 5.0.0, and change the entire project to work with CommonJS ES6 (import instead of require), and for some reason I keep getting:
Error [ERR_REQUIRE_ESM]: require() of ES Module C:\node_modules\log-update\index.js from C:\src\utils\files\log.utils.js not supported.
Instead change the require of index.js in C:\src\utils\files\log.utils.js to a dynamic import() which is available in all CommonJS modules.
courses\node_modules\@babel\node\lib\_babel-node.js:176:21) {
code: 'ERR_REQUIRE_ESM'
}
npm ERR! code 1
npm ERR! path C:\Web
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c babel-node src/scripts/initiate.script.js
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\AppData\Local\npm-cache\_logs\2022-01-01T17_56_21_202Z-debug-0.log
I looked at:
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
require() of ES Module not supported
Error [ERR_REQUIRE_ESM]: require() of ES Module
But none of them working for me.
Any idea?
Thanks.
In the end I just converted the project into pure ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c And it works for me.