Skip to content

Commit

Permalink
android: fix NODE_PATH needed for rn-bridge
Browse files Browse the repository at this point in the history
safeGetenv() was changed in nodejs/node@3f61940
so now on Android it's returning undefined. With NODE_PATH as
undefined, then custom nodejs-mobile-react-native builtins such as
don't get found by the cjs loader, which means rn-bridge isn't found.

However, it seems like we can safely get NODE_PATH from process.env
because NODE_PATH is explicitly overwritten by
nodejs-mobile-react-native, so it's not possible that it would take
other values by third parties.
  • Loading branch information
staltz committed Oct 12, 2023
1 parent 8b5b938 commit a8a59e7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1383,7 +1383,7 @@ Module.createRequire = createRequire;

Module._initPaths = function() {
const homeDir = isWindows ? process.env.USERPROFILE : safeGetenv('HOME');
const nodePath = isWindows ? process.env.NODE_PATH : safeGetenv('NODE_PATH');
const nodePath = process.env.NODE_PATH; // nodejs-mobile patch

// process.execPath is $PREFIX/bin/node except on Windows where it is
// $PREFIX\node.exe where $PREFIX is the root of the Node.js installation.
Expand Down

0 comments on commit a8a59e7

Please sign in to comment.