Select the directory option from the above "Directory" header!

Node.js upgrade adds environment variable config

Node.js upgrade adds environment variable config

The JavaScript runtime also boasts ECMAScript modules.

Credit: Dreamstime

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 initialise 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 customisation 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="" 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.

Follow Us

Join the newsletter!


Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.

Tags javascriptNode.js

Show Comments