windows: use USERPROFILE to get the user's home dir
Fixes #3461 Close #3462 Close #4093
This commit is contained in:
parent
76ddf06f10
commit
5288ed75be
@ -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.USERPROFILE;
|
||||
} else {
|
||||
var homeDir = process.env.HOME;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user