CommonJS compatibility issues with ceramic-client library

Hey all. We are developing in a node environment and are having some incompatibility issues with the ESM packaging on the http client. We are seeing an ERR_REQUIRE_ESM when attempting to import the http-client module:

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/varunp/Documents/protocol/node_modules/@ceramicnetwork/http-client/lib/ceramic-http-client.js from /Users/varunp/Documents/protocol/packages/persistence/src/cloud/CeramicCloudStorage.ts not supported.
Instead change the require of ceramic-http-client.js in /Users/varunp/Documents/protocol/packages/persistence/src/cloud/CeramicCloudStorage.ts to a dynamic import() which is available in all CommonJS modules.

Is there a version of the http-client that is packaged with commonJS (for example an older version we can pin to)?

Hi @varunp_sdl, welcome to the forum!

To answer your question, it might be difficult to find a HTTP client version that doesn’t use ESM but that’s still new enough to be compatible with a reasonably new Ceramic Core. Otherwise you might be forced to use a version of the Core that is missing many important bug fixes and enhancements, and moreover might have issues interacting with other nodes on the network.

Still, tagging @ukstv in case he has an answer regarding an older (usable) version of the client, or some alternative.

You could try using ceramic client v1, which is packaged as CJS. There is no guarantee though, that it will work against a v2 Ceramic node.

Just in case, Node.js can do ESM just fine. Maybe you could transition your app to ESM.