Node.js 23 Enhances Module and Testing Support

/ JavaScript, Node.js, ES-Modules, Software Development

The open-source JavaScript runtime environment Node.js has unveiled its 23rd version, introducing several notable updates. Released on an unspecified date, Node.js 23 enhances support for native ES modules and modifies testing functionalities, primarily affecting developers utilizing JavaScript for server-side applications.

Key Updates in Node.js 23

In this latest iteration, Node.js has made <code>require(esm)</code> support a default feature. Previously, this was only available with the command-line flag --experimental-require-module in versions like 20.x and 22.x. By standardizing this feature, Node.js allows native ES modules to be loaded through require(); however, it remains in an experimental phase, and user feedback is solicited for further refinements before finalization.

The transition to seamlessly supporting native ES modules comes with a few caveats. An experimental warning will occur when an ES module is detected using require(). Users encountering issues can report them on the Node.js issue tracker. If necessary, the feature can be temporarily disabled using --no-experimental-require-module. A more comprehensive implementation is expected in a future minor update once Node.js 22 becomes the official Long-Term Support (LTS) version.

Improving Error Management

Node.js 23 also addresses previous issues by preventing the ERR_REQUIRE_ESM error when require() is used to load ES modules. However, developers might encounter the ERR_REQUIRE_ASYNC_MODULE if a module or its dependencies include a top-level await statement. Successfully loaded ES modules return a namespace object, verifiable with util.isModuleNamespaceObject().

To further ease the development experience, users can check if the require(esm) support is active in their current Node.js instance using process.features.require_module. Additionally, the "module-sync" exports condition within packages now permits both require() and import to effectively load the same native ES module. Developers seeking more details can refer to the updated documentation.

Node.js 22 and Its Long-Term Support

As Node.js 23 takes over as the latest release version, Node.js 22 is transitioning to Long-Term Support within October 2023, ensuring continued stability for applications dependent on older versions. According to its release schedule, Node.js 23 will remain in its current version status for the next six months until April 2025.

Developers interested in further technical specifics can refer to the release notes for Node.js 23.

Additionally, the enterprise JavaScript conference, enterJS 2025, is slated for May 7-8 in Mannheim. Organizers are currently seeking proposals for talks and workshops, with submissions due by November 8, 2024. Early bird tickets are on sale for those interested in attending.

For more in-depth coverage, this was reported on by heise online.

Next Post Previous Post