Home > Mobile >  Node 16: is the --experimental-json-modules CLI flag still required?
Node 16: is the --experimental-json-modules CLI flag still required?

Time:09-23

I have been using the --experimental-json-modules flag for a while now, to allow me to import JSON, like so:

import data from './data.json' assert { type: 'json' };

I've recently tried leaving the --experimental-json-modules flag out of the command that runs the node app, and I'm not getting any complaints (and it still seems to work OK).

I'm using the latest recommended node version 16.17.0.

So is this flag required any more, or not? The only mention of it in the release notes for node 16 is the entry for 16.14.0:

To keep Node.js ESM implementation as compatible as possible with the HTML spec, import assertions are now required to import JSON modules (still behind the --experimental-json-modules CLI flag)

So there was some change, but my reading of the above is that the --experimental-json-modules CLI flag is still required? Except that it doesn't seem to be?

CodePudding user response:

This merge request, which as been merged, mentions:

This PR unflags JSON modules, removing the --experimental-json-modules flag.

In the changelog for 16.15.1 you can find this in the section "other notable changes":

(SEMVER-MINOR) unflag esm json modules (Geoffrey Booth)

  • Related