Paul Krill
Editor at Large

Node.js upgrade adds environment variable config

news
Sep 6, 20232 mins

The JavaScript runtime also boasts ECMAScript modules.

upgrade arrows
Credit: Gerd Altmann

Node.js 20.6.0, the latest version of the asynchronous, event-driven JavaScript runtime, includes built-in env. file support for configuring environment variables.

The update, cited as the “current” version of Node.js and announced September 4, can be downloaded from the project website. With env., Node.js proponents said the configuration file should follow the INI file format, with each line having a key-value pair for an environment variable. To initialize the Node.js application with predefined configurations, developers can use this CLI command: node—file=config.env index.js. In addition, the change for environment variables enables definition of NODE_OPTIONS directly in the .env file, eliminating the need to put it in package.json.

Also in Version 20.6.0, in ECMAScript modules, import.meta.resolve(specifier) can be used to obtain an absolute URL string to which specifier. And a new register API, available on node.module, enables specification of a file that exports module customization hooks. Data can be passed to these hooks.

Elsewhere in Node.js 20.60.0:

  • When Node.js starts up, it now ensures there is a v8::CppHeap attached to the V8 isolate. This lets users allocate in the v8::CppHeap using <cppgc/*> headers from the V8 JavaScript engine, which are now included in the Node.js headers available to add-ons.
  • To help with development of JavaScript-to-C++ references, of which the V8 garbage collector can be aware, a helper function, <a href="https://github.com/nodejs/node/blob/v20.6.0/test/addons/cppgc-object/binding.cc" rel="nofollow">node::SetCppgcReference(isolate, js_object, cppgc_object)</a> has been added to node.h. This API can be used to avoid hard-coding the layout of JavaScript wrapper objects. V8 may provide a native alternative in the future, which could replace this Node.js-specific helper.
Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author