diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index 7b67efac2390e8..44c35718735426 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -661,9 +661,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,