diff --git a/lib/internal/bootstrap/loaders.js b/lib/internal/bootstrap/loaders.js index 4a5e962092d790..960ff07221349d 100644 --- a/lib/internal/bootstrap/loaders.js +++ b/lib/internal/bootstrap/loaders.js @@ -46,6 +46,7 @@ const { ArrayPrototypeMap, ArrayPrototypePush, + ArrayPrototypeSlice, Error, ObjectCreate, ObjectDefineProperty, @@ -239,8 +240,10 @@ class NativeModule { const { ModuleWrap } = internalBinding('module_wrap'); const url = `node:${this.id}`; const nativeModule = this; + const exportsKeys = ArrayPrototypeSlice(this.exportKeys); + ArrayPrototypePush(exportsKeys, 'default'); this.module = new ModuleWrap( - url, undefined, [...this.exportKeys, 'default'], + url, undefined, exportsKeys, function() { nativeModule.syncExports(); this.setExport('default', nativeModule.exports);