method
vm.SyntheticModule.setExport
name: string,
value: any
): void;
This method sets the module export binding slots with the given value.
import vm from 'node:vm';
const m = new vm.SyntheticModule(['x'], () => {
m.setExport('x', 1);
});
await m.evaluate();
assert.strictEqual(m.namespace.x, 1);@param name
Name of the export to set.
@param value
The value to set the export to.