Skip to content

Commit

Permalink
module: fix loading from global folders on Windows
Browse files Browse the repository at this point in the history
Code was calculating $PREFIX/lib/node relative to process.execPath, but
on Windows process.execPath is $PREFIX\node.exe whereas everywhere else
process.execPath is $PREFIX/bin/node (where $PREFIX is the root of the
installed Node.js).

PR-URL: nodejs#9283
Reviewed-By: Sam Roberts <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: João Reis <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
  • Loading branch information
richardlau authored and gibfahn committed Mar 11, 2017
1 parent 92e7c93 commit 055482c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,16 @@ Module._initPaths = function() {
homeDir = process.env.HOME;
}

var paths = [path.resolve(process.execPath, '..', '..', 'lib', 'node')];
// $PREFIX/lib/node, where $PREFIX is the root of the Node.js installation.
var prefixDir;
// process.execPath is $PREFIX/bin/node except on Windows where it is
// $PREFIX\node.exe.
if (isWindows) {
prefixDir = path.resolve(process.execPath, '..');
} else {
prefixDir = path.resolve(process.execPath, '..', '..');
}
var paths = [path.resolve(prefixDir, 'lib', 'node')];

if (homeDir) {
paths.unshift(path.resolve(homeDir, '.node_libraries'));
Expand Down

0 comments on commit 055482c

Please sign in to comment.