• name {string} Name of the export to set.
    • value {any} The value to set the export to.

    This method is used after the module is linked to set the values of exports. If it is called before the module is linked, an [ERR_VM_MODULE_STATUS][] error will be thrown.

    1. const vm = require('vm');
    2. (async () => {
    3. const m = new vm.SyntheticModule(['x'], () => {
    4. m.setExport('x', 1);
    5. });
    6. await m.link(() => {});
    7. await m.evaluate();
    8. assert.strictEqual(m.namespace.x, 1);
    9. })();