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);
Search the reference...
/
method
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);
Name of the export to set.
The value to set the export to.
Resources
ReferenceDocsGuidesDiscordMerch StoreGitHubBlogToolkit
RuntimePackage managerTest runnerBundlerPackage runnerProject
Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San Francisco
We're hiring →