From a375c6ae9a37db31210996a45c8646d3b32ebfe3 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 15 Nov 2010 10:22:24 -0800 Subject: [PATCH] Revert node_module lookup commits Revert "Add ~/.node_modules as well as ~/.node_libraries" This reverts commits 5e14c8bec0b4e1c19d8567cf8b843b215e8796ac. b0adaff67e492ab9ac583059f5e2dba54de0973b. 492fc0d7524c0a5b546fb1a16f1b49bb4db73da8. --- src/node.js | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/src/node.js b/src/node.js index 04ad4b9e3d..f89db7904a 100644 --- a/src/node.js +++ b/src/node.js @@ -126,21 +126,15 @@ var module = (function () { var pathModule = createInternalModule('path', pathFn); var path = pathModule.exports; - // The paths that the user has specifically asked for. Highest priority. - // This is what's hung on require.paths. - var modulePaths = []; - if (process.env.NODE_PATH) { - modulePaths = process.env.NODE_PATH.split(":"); + var modulePaths = [path.join(process.execPath, "..", "..", "lib", "node")]; + + if (process.env["HOME"]) { + modulePaths.unshift(path.join(process.env["HOME"], ".node_libraries")); } - // The default global paths that are always checked. - // Lowest priority. - var defaultPaths = []; - if (process.env.HOME) { - defaultPaths.push(path.join(process.env.HOME, ".node_modules")); - defaultPaths.push(path.join(process.env.HOME, ".node_libraries")); + if (process.env["NODE_PATH"]) { + modulePaths = process.env["NODE_PATH"].split(":").concat(modulePaths); } - defaultPaths.push(path.join(process.execPath, "..", "..", "lib", "node")); var extensions = {}; var registerExtension = removed('require.registerExtension() removed. Use require.extensions instead'); @@ -171,7 +165,7 @@ var module = (function () { } function findModulePath (request, paths) { - var nextLoc = traverser(request, paths); + var nextLoc = traverser(request, request.charAt(0) === '/' ? [''] : paths); var fs = requireNative('fs'); @@ -183,29 +177,15 @@ var module = (function () { return false; } - function modulePathWalk (parent) { - if (parent._modulePaths) return parent._modulePaths; - var p = parent.filename.split("/"); - var mp = []; - while (undefined !== p.pop()) { - mp.push(p.join("/")+"/node_modules"); - } - return parent._modulePaths = mp; - } // sync - no i/o performed function resolveModuleLookupPaths (request, parent) { if (natives[request]) return [request, []]; - if (request.charAt(0) === '/') { - return [request, ['']]; - } - var start = request.substring(0, 2); if (start !== "./" && start !== "..") { - var paths = modulePaths.concat(modulePathWalk(parent)).concat(defaultPaths); - return [request, paths]; + return [request, modulePaths]; } // Is the parent an index module?