setExport

fun setExport(name: String, value: Any?)(source)

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);

Since

v13.0.0, v12.16.0

Parameters

name

Name of the export to set.

value

The value to set the export to.