Skip to main content
Module.syncBuiltinESMExports - node__module.d.ts - Node documentation
function Module.syncBuiltinESMExports

Usage in Deno

```typescript import { Module } from "node:node__module.d.ts"; ```
syncBuiltinESMExports(): void
The `module.syncBuiltinESMExports()` method updates all the live bindings for builtin `ES Modules` to match the properties of the `CommonJS` exports. It does not add or remove exported names from the `ES Modules`. ```js import fs from 'node:fs'; import assert from 'node:assert'; import { syncBuiltinESMExports } from 'node:module'; fs.readFile = newAPI; delete fs.readFileSync; function newAPI() { // ... } fs.newAPI = newAPI; syncBuiltinESMExports(); import('node:fs').then((esmFS) => { // It syncs the existing readFile property with the new value assert.strictEqual(esmFS.readFile, newAPI); // readFileSync has been deleted from the required fs assert.strictEqual('readFileSync' in fs, false); // syncBuiltinESMExports() does not remove readFileSync from esmFS assert.strictEqual('readFileSync' in esmFS, true); // syncBuiltinESMExports() does not add names assert.strictEqual(esmFS.newAPI, undefined); }); ```

Return Type

void