4 min read

Node.js v10.12.0 was released, yesterday, with notable changes to assert, cli, crypto, fs, and more. However, the Node.js API is still somewhat changing, and as it matures, certain parts are more reliable than others. Hence throughout the v10.12.0 documentation are indications of a section’s stability.

Let’s look at the notable changes which are stable.

Assert module

Changes have been made to assert. The assert module provides a simple set of assertion tests that can be used to test invariants. It comprises of a strict mode and a legacy mode, although it is recommended to only use strict mode.

In Node.js v10.12.0, the diff output is now improved by sorting object properties when inspecting the values that are compared with each other.

Changes to cli

The command line interface in Node.js v10.12.0 has two improvements:

  • The options parser now normalizes _ to – in all multi-word command-line flags, e.g. –no_warnings has the same effect as –no-warnings.
  • It also includes bash completion for the node binary. Users can generate a bash completion script with run node –completion-bash. The output can be saved to a file which can be sourced to enable completion.

Crypto Module

The crypto module provides cryptographic functionality that includes a set of wrappers for OpenSSL’s hash, HMAC, cipher, decipher, sign, and verify functions. In Node.js v10.12.0, crypto adds support for PEM-level encryption.

It also supports API asymmetric key pair generation. The new methods crypto.generateKeyPair and crypto.generateKeyPairSync can be used to generate public and private key pairs. The API supports RSA, DSA and EC and a variety of key encodings (both PEM and DER).

Improvements to file system

The fs module provides an API for interacting with the file system in a manner closely modeled around standard POSIX functions.

Node.js v10.12.0 adds a recursive option to fs.mkdir and fs.mkdirSync. On setting this option to true, non-existing parent folders will be automatically created.

Updates to Http/2

The http2 module provides an implementation of the HTTP/2 protocol. The new node.js version adds support for a ‘ping’ event to Http2Session that is emitted whenever a non-ack PING is received.

Support is also added for the ORIGIN frame.  Also, nghttp2 is updated to v1.34.0. This adds RFC 8441 extended connect protocol support to allow the use of WebSockets over HTTP/2.

Changes in module

In the Node.js module system, each file is treated as a separate module. Module has also been updated in v10.12.0. It adds module.createRequireFromPath(filename). This new method can be used to create a custom require function that will resolve modules relative to the filename path.

Improvements to process

The process object is a global that provides information about, and control over, the current Node.js process. Process adds a ‘multipleResolves’ process event that is emitted whenever a Promise is attempted to be resolved multiple times.

Updates to url

Node.js v10.12.0 adds url.fileURLToPath(url) and url.pathToFileURL(path). These methods can be used to correctly convert between file: URLs and absolute paths.

Changes in Utilities

The util module is primarily designed to support the needs of Node.js’ own internal APIs. The changes in Node.js v10.12.0 include:

  • A new sorted option is added to util.inspect(). If set to true, all properties of an object and Set and Map entries will be sorted in the returned string. If set to a function, it is used as a compare function.
  • The util.instpect.custom symbol is now defined in the global symbol registry as Symbol.for(‘ nodejs.util.inspect.custom’).
  • Support for BigInt numbers in util.format() are also added.

Improvements in V8 API

The V8 module exposes APIs that are specific to the version of V8 built into the Node.js binary. A number of V8 C++ APIs in v10.12.0 have been marked as deprecated since they have been removed in the upstream repository. Replacement APIs are added where necessary.

Changes in Windows

The Windows msi installer now provides an option to automatically install the tools required to build native modules.

You can find the list of full changes on the Node.js Blog.

Read Next

Node.js and JS Foundation announce intent to merge; developers have mixed feelings.

Node.js announces security updates for all their active release lines for August 2018.

Deploying Node.js apps on Google App Engine is now easy.


Subscribe to the weekly Packt Hub newsletter. We'll send you the results of our AI Now Survey, featuring data and insights from across the tech landscape.

* indicates required