Skip to content

Commit ffe969a

Browse files
committed
fix windows cache path lookup
1 parent 10a0650 commit ffe969a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/internal/loader/ModuleRequest.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,12 @@ loaders.set('esm', async (url) => {
3636
});
3737

3838
// Strategy for loading a node-style CommonJS module
39+
const isWindows = process.platform === 'win32';
40+
const winSepRegEx = /\//g;
3941
loaders.set('cjs', async (url) => {
4042
const pathname = internalURLModule.getPathFromURL(new URL(url));
41-
const module = CJSModule._cache[pathname];
43+
const module = CJSModule._cache[
44+
isWindows ? pathname.replace(winSepRegEx, '\\') : pathname];
4245
if (module && module.loaded) {
4346
const ctx = createDynamicModule(['default'], url, undefined);
4447
ctx.reflect.exports.default.set(module.exports);

0 commit comments

Comments
 (0)