Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

windows: use USERPROFILE to get the user's home dir #4093

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+13 −5
Split
View
@@ -497,16 +497,24 @@ Module.runMain = function() {
Module._load(process.argv[1], null, true);
};
-Module._initPaths = function() {
+Module._initPaths = function () {
+ var isWindows = process.platform === 'win32';
+
+ if (!isWindows) {
+ var homeDir = process.env.HOME;
+ } else {
+ var homeDir = process.env.USERPROFILE;
+ }
+
var paths = [path.resolve(process.execPath, '..', '..', 'lib', 'node')];
- if (process.env['HOME']) {
- paths.unshift(path.resolve(process.env['HOME'], '.node_libraries'));
- paths.unshift(path.resolve(process.env['HOME'], '.node_modules'));
+ if (homeDir) {
+ paths.unshift(path.resolve(homeDir, '.node_libraries'));
+ paths.unshift(path.resolve(homeDir, '.node_modules'));
}
if (process.env['NODE_PATH']) {
- var splitter = process.platform === 'win32' ? ';' : ':';
+ var splitter = isWindows ? ';' : ':';
paths = process.env['NODE_PATH'].split(splitter).concat(paths);
}