Solving the CommonJS (Common JavaScript) and ECMAScript Modules (ESM) Problem

The following is a solution graciously provided by a Chilkat user trying to convert a node16 application using Common JS (require) to node20 using ESM (import). CommonJS (Common JavaScript) and ECMAScript Modules (ESM) are two different module systems used in JavaScript environments. CommonJS is the module system used in Node.js and is characterized by `require()` and `module.exports` syntax, while ECMAScript […]

Error: Node.js requires NODE_MODULE_VERSION 72

Question: I am trying to use the Node.js library with node installed through home-brew, but I get this error when executing an example script: Error: The module ‘/Users/x/node_modules/@chilkat/ck-node11-macosx/chilkat.node’ was compiled against a different Node.js version using NODE_MODULE_VERSION 67. This version of Node.js requires NODE_MODULE_VERSION 72. Please try re-compiling or re-installing the module (for instance, using `npm rebuild` or `npm install`). […]

Node.js Asynchronous Methods that Return Objects

This post shows the general technique to get the object returned by a method when it is called asynchronously.   For example, consider the Mailman.GetUidls() method.  A synchronous call to GetUidls returns a StringArray object, as shown here: However, the async version of the method, GetUidlsAsync, returns a Task object. The TaskCompleted callback is called when finished. The following code […]

Asynchronous Chilkat Methods in Node.js

Chilkat implements a thread pool for asynchronous tasks in all programming languages except for Node.js. For Node.js, Chilkat tasks run directly on Node’s internal thread pool (i.e. the libuv thread pool). The Task.Run() method can have 0 or 1 arguments. If an argument is passed, it is the “task completed” callback that get called when the task has completed. Here […]