constructor(options = {}) {
    super();

    // defaults
    this.options = {
      sandbox: options.sandbox,
      console: options.console || 'inherit',
      require: options.require || false,
      compiler: options.compiler || 'javascript',
      eval: options.eval === false ? false : true,
      wasm: options.wasm === false ? false : true,
      nesting: options.nesting || false,
      wrapper: options.wrapper || 'commonjs',
      sourceExtensions: options.sourceExtensions || ['js']
    };

    const host = {
      version: parseInt(process.versions.node.split('.')[0]),
      require,
      process,
      console,
      setTimeout,
      setInterval,
      setImmediate,
      clearTimeout,
      clearInterval,
      clearImmediate,
      String,
      Number,
      Buffer,
      Boolean,
      Array,
      Date,
      Error,
      EvalError,
      RangeError,
      ReferenceError,
      SyntaxError,
      TypeError,
      URIError,
      RegExp,
      Function,
      Object,
      VMError,
      Proxy,
      Reflect,
      Map,
      WeakMap,
      Set,
      WeakSet,
      Promise,
      Symbol
    };

    if (this.options.nesting) {
      host.VM = VM;
      host.NodeVM = NodeVM;
    }

    this._context = vm.createContext(undefined, {
      codeGeneration: {
        strings: this.options.eval,
        wasm: this.options.wasm
      }
    });

    Object.defineProperty(this, '_internal', {
      value: SCRIPT_CACHE.cf._compiledVM
        .runInContext(this._context, {
          filename: SCRIPT_CACHE.cf.filename,
          displayErrors: false
        })
        .call(this._context, require, host)
    });

    const closure = SCRIPT_CACHE.sb._compiledVM.runInContext(this._context, {
      filename: SCRIPT_CACHE.sb.filename,
      displayErrors: false
    });

    Object.defineProperty(this, '_prepareRequire', {
      value: closure.call(this._context, this, host, this._internal.Contextify, this._internal.Decontextify, this._internal.Buffer)
    });

    // prepare global sandbox
    if (this.options.sandbox) {
      if ('object' !== typeof this.options.sandbox) {
        throw new VMError('Sandbox must be object.');
      }

      for (const name in this.options.sandbox) {
        if (Object.prototype.hasOwnProperty.call(this.options.sandbox, name)) {
          this._internal.Contextify.globalValue(this.options.sandbox[name], name);
        }
      }
    }

    if (this.options.require && this.options.require.import) {
      if (!Array.isArray(this.options.require.import)) {
        this.options.require.import = [this.options.require.import];
      }

      for (let i = 0, l = this.options.require.import.length; i < l; i++) {
        this.require(this.options.require.import[i]);
      }
    }
  }
Create NodeVM instance.

Unlike VM, NodeVM lets you use require same way like in regular node.

@param {Object} [options] VM options.
@return {NodeVM}