Skip to main content
SyntheticModule.prototype.setExport - node__vm.d.ts - Node documentation
method SyntheticModule.prototype.setExport

Usage in Deno

```typescript import { SyntheticModule } from "node:node__vm.d.ts"; ```
SyntheticModule.prototype.setExport(
name: string,
value: any,
): void
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. ```js import vm from 'node:vm'; const m = new vm.SyntheticModule(['x'], () => { m.setExport('x', 1); }); await m.link(() => {}); await m.evaluate(); assert.strictEqual(m.namespace.x, 1); ```

Parameters

name: string
Name of the export to set.
value: any
The value to set the export to.

Return Type

void