From ff188f5cf63c58e2a3ad3baa22a6f1626da775a8 Mon Sep 17 00:00:00 2001 From: jgor20 <102353650+jgor20@users.noreply.github.com> Date: Mon, 5 Jan 2026 01:09:00 +0000 Subject: [PATCH] fix(utils): fix cross-platform root detection in findPackageRoot Improve the findPackageRoot function to correctly detect filesystem root on all platforms by checking if dirname returns the same path, replacing the Unix-specific '/' check. --- src/utils/native-module-helper.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/utils/native-module-helper.js b/src/utils/native-module-helper.js index d5285b7..9a1d6fa 100644 --- a/src/utils/native-module-helper.js +++ b/src/utils/native-module-helper.js @@ -41,12 +41,17 @@ export function extractModulePath(error) { export function findPackageRoot(nodeFilePath) { // Walk up from the .node file to find package.json let dir = dirname(nodeFilePath); - while (dir && dir !== '/') { + while (dir) { const packageJsonPath = join(dir, 'package.json'); if (existsSync(packageJsonPath)) { return dir; } - dir = dirname(dir); + const parentDir = dirname(dir); + // Stop when we've reached the filesystem root (dirname returns same path) + if (parentDir === dir) { + break; + } + dir = parentDir; } return null; }