diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index 428f5452c6d26d..5d4ae26c02ebbd 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -648,9 +648,11 @@ Module.prototype.load = function(filename) { // Create module entry at load time to snapshot exports correctly const exports = this.exports; if (module !== undefined) { // Called from cjs translator - module.reflect.onReady((reflect) => { - reflect.exports.default.set(exports); - }); + if (module.reflect) { + module.reflect.onReady((reflect) => { + reflect.exports.default.set(exports); + }); + } } else { // preemptively cache ESMLoader.moduleMap.set( url,