BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Node.js 2023 Edition Available

Node.js 2023 Edition Available

This item in japanese

The Node.js team has recently released version 20.6.0, which brings improvements in environment variable configuration, module resolution, module customization, and experimental support for C++ garbage collection.

In this patch, developers gain a new feature: built-in support for `.env` files. These files, following the INI file format, offer a simplified approach to configuring environment variables. Developers can easily initialize their applications with predefined configurations using a straightforward CLI command, `node --env-file=config.env index.js`. This update streamlines the management of environment variables.

Another notable change involves the unflagged `import.meta.resolve(specifier)` function. This adjustment plays a crucial role in aligning Node.js with other server-side runtimes and browsers. The function now provides an absolute URL string for module resolution, enhancing cross-platform compatibility and simplifying module management across different environments.

Node.js 20.6.0 also introduced a new API known as `register` within the `node:module` namespace. This API simplifies module customization hooks, enabling developers to specify a file that exports these hooks and facilitates communication channels between the main application thread and the hooks thread. Developers are encouraged to transition to an approach that uses `--import` alongside `register` for efficient hook registration.

Node.js 20.6.0 enhanced the module customization load hook, allowing it to manage both ES module and CommonJS sources. This added flexibility streamlines the process of loading and customizing Node.js modules, eliminating the dependence on deprecated APIs.

Node.js C++ addons now feature experimental support for a C++ garbage collector, enhancing compatibility with V8's memory management. This support ensures Node.js starts with a `v8::CppHeap`, allowing memory allocation using `<cppgc/*>` headers from V8. While stability may vary in minor and patch updates, the C++ garbage collector has a strong track record in Chromium, making it a promising choice for C++ addon development.

Node.js 20, released in April 2023, brought significant changes, including embracing ES2023, experimental support for the WebAssembly System Interface (WASI), and a focus on performance and stability with the V8 JavaScript engine updated to version 11.3. The release enhanced security was enhanced with the introduction of an experimental permission model, featured a stable test runner, and introduced capabilities for single executable apps, enabling the distribution of Node.js apps on systems without Node.js installed. These developments, combined with support for new operating systems, improved TypeScript compatibility, and the introduction of new developer tools and APIs solidify Node.js.

Node.js 20 is currently in its beta phase and is set to transition to long-term support (LTS) on October 24, 2023. This means that it will receive ongoing support, including security updates and bug fixes, for a minimum of three years.

About the Author

Rate this Article

Adoption
Style

BT