Skip to content

Commit

Permalink
fix: node 22 module filename resolution in win32 (#49) by @faulpeltz
Browse files Browse the repository at this point in the history
  • Loading branch information
faulpeltz authored Sep 24, 2024
1 parent 9beb250 commit e436d74
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions patches/node.v22.9.0.cpp.patch
Original file line number Diff line number Diff line change
Expand Up @@ -327,17 +327,23 @@ index 0000000000..a697294fdf
+ }());
+}());
diff --git node/lib/internal/modules/cjs/loader.js node/lib/internal/modules/cjs/loader.js
index 451b7c2195..203be65195 100644
index 451b7c2195..7733dfb3d6 100644
--- node/lib/internal/modules/cjs/loader.js
+++ node/lib/internal/modules/cjs/loader.js
@@ -234,7 +234,10 @@ function stat(filename) {
@@ -229,12 +229,16 @@ function wrapModuleLoad(request, parent, isMain) {
* @param {string} filename Absolute path to the file
*/
function stat(filename) {
+ const origFilename = filename;
filename = path.toNamespacedPath(filename);
if (statCache !== null) {
const result = statCache.get(filename);
if (result !== undefined) { return result; }
}
- const result = internalFsBinding.internalModuleStat(filename);
+ const fs = require('fs');
+ const result = fs.existsSync(filename) ?
+ (fs.statSync(filename).isDirectory() ? 1 : 0) : -1;
+ const result = fs.existsSync(origFilename) ?
+ (fs.statSync(origFilename).isDirectory() ? 1 : 0) : -1;
+
if (statCache !== null && result >= 0) {
// Only set cache when `internalModuleStat(filename)` succeeds.
Expand Down

0 comments on commit e436d74

Please sign in to comment.