You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/sven/projects/zapdb-kv/node_modules/big-varint/lib/index.js
require() of ES modules is not supported.
require() of /home/sven/projects/zapdb-kv/node_modules/big-varint/lib/index.js from /home/sven/projects/zapdb-kv/src/storage-encoder/encode.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 index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/sven/projects/zapdb-kv/node_modules/big-varint/package.json.
Unfortunately, while it's possible to import CJS modules from ESM code, the other way around is not possible (or at least not when using "type": "module"), so for maximum compatibility a library should use CJS-compatible exports.
The text was updated successfully, but these errors were encountered:
so for maximum compatibility a library should use CJS-compatible exports
I understand that ESM modules are less “compatible”, but they’re clearly the best way to build and distribute libraries going forward. See this explanation by Sindre Sorhus.
Requiring this module like so:
... produces the following error:
Unfortunately, while it's possible to import CJS modules from ESM code, the other way around is not possible (or at least not when using
"type": "module"
), so for maximum compatibility a library should use CJS-compatible exports.The text was updated successfully, but these errors were encountered: