Change8

v20.19.0

Breaking Changes
📦 node-jsView on GitHub →
2 breaking9 features🐛 4 fixes1 deprecations🔧 6 symbols

Summary

This release enables require(esm) and module syntax detection by default on Node.js v20.x. It also introduces the postMessageToThread worker API and updates several core dependencies including ICU, NSS, and Corepack.

⚠️ Breaking Changes

  • require(esm) is now enabled by default on v20.x. While intended to be backward compatible, it changes the behavior of require() when targeting ES modules, which may now return a namespace object instead of throwing ERR_REQUIRE_ESM. Use --no-experimental-require-module to revert if regressions occur.
  • Module syntax detection is now enabled by default. Ambiguous .js files without a package.json 'type' field may now be interpreted as ES modules if they contain ESM syntax, which could change execution behavior for previously failing or ambiguous scripts.

Migration Steps

  1. If using v20.x and experiencing issues with require() loading ES modules, use the --no-experimental-require-module flag.
  2. To avoid the performance penalty of module syntax detection, explicitly add 'type': 'module' or 'type': 'commonjs' to your package.json.
  3. If module syntax detection causes issues, use the --no-experimental-detect-module flag.
  4. Update any code relying on ERR_REQUIRE_ESM to handle the new behavior where require() may succeed or throw ERR_REQUIRE_ASYNC_MODULE.

✨ New Features

  • Enabled require(esm) by default on v20.x, allowing synchronous loading of ES modules via require() (provided no top-level await is used).
  • Enabled module syntax detection by default for ambiguous files.
  • Added worker.postMessageToThread.
  • Added process.features.require_module to detect support for synchronous ESM loading.
  • Implemented the 'module-sync' exports condition for package.json.
  • Added __esModule property to ES modules loaded via require().
  • Updated root certificates to NSS 3.107.
  • Updated Corepack to 0.31.0.
  • Updated ICU to 76.1 and Timezone to 2025a.

🐛 Bug Fixes

  • Fixed child_process parsing issues with messages containing split length fields.
  • Fixed build compatibility with V8's depot_tools.
  • Added missing return value check in crypto module.
  • Fixed styles of the expandable documentation TOC.

Affected Symbols

⚡ Deprecations

  • The libc++ macro ENODATA is deprecated.