diff --git a/js/private/node-patches/register.js b/js/private/node-patches/register.js index 934d902f7..607afeb37 100644 --- a/js/private/node-patches/register.js +++ b/js/private/node-patches/register.js @@ -35,7 +35,8 @@ if ( JS_BINARY__PATCH_NODE_FS != '0' && JS_BINARY__FS_PATCH_ROOTS ) { - const fs = require('fs') + const fs = require('node:fs') + const module = require('node:module') const roots = JS_BINARY__FS_PATCH_ROOTS.split(':') if (JS_BINARY__LOG_DEBUG) { console.error( @@ -43,4 +44,8 @@ if ( ) } patchfs(fs, roots) + + // Sync the esm modules to use the now patched fs cjs module. + // See: https://nodejs.org/api/esm.html#builtin-modules + module.syncBuiltinESMExports() }