Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ba91c41

Browse filesBrowse files
richardlauMylesBorins
authored andcommitted
module: fix loading from global folders on Windows
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: #9283 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: João Reis <reis@janeasystems.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent 1dc6b38 commit ba91c41
Copy full SHA for ba91c41

File tree

Expand file treeCollapse file tree

1 file changed

+10
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-1
lines changed
Open diff view settings
Collapse file

‎lib/module.js‎

Copy file name to clipboardExpand all lines: lib/module.js
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,16 @@ Module._initPaths = function() {
453453
homeDir = process.env.HOME;
454454
}
455455

456-
var paths = [path.resolve(process.execPath, '..', '..', 'lib', 'node')];
456+
// $PREFIX/lib/node, where $PREFIX is the root of the Node.js installation.
457+
var prefixDir;
458+
// process.execPath is $PREFIX/bin/node except on Windows where it is
459+
// $PREFIX\node.exe.
460+
if (isWindows) {
461+
prefixDir = path.resolve(process.execPath, '..');
462+
} else {
463+
prefixDir = path.resolve(process.execPath, '..', '..');
464+
}
465+
var paths = [path.resolve(prefixDir, 'lib', 'node')];
457466

458467
if (homeDir) {
459468
paths.unshift(path.resolve(homeDir, '.node_libraries'));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.