How to detect if an --experimental flag is enabled in Node

Viewed 11

I have some code that needs to work slightly differently depending on whether the --experimental-vm-modules is enabled.

I'm currently checking for the presence of an object that only exists if the flag is enabled.

function escapePathForImport(path) {
  // If --experimental-vm-modules is enabled
  // (there may be a better way to detect this)
  if (vm.Module) {
    return path;
  }

  return escape(path);
}

That works, but I'm curious if there's a more direct way to detect if a particular --experimental-* flag is enabled.

0 Answers
Related