From 5e14c8bec0b4e1c19d8567cf8b843b215e8796ac Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 19 Oct 2010 13:28:13 -0700 Subject: [PATCH] Add ~/.node_modules as well as ~/.node_libraries --- doc/api.markdown | 12 ++++++------ src/node.js | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/doc/api.markdown b/doc/api.markdown index 9f8d76546c..0e5fc6f126 100644 --- a/doc/api.markdown +++ b/doc/api.markdown @@ -3241,15 +3241,15 @@ Without the leading `'./'`, like `require('assert')` the module is searched for in the `require.paths` array. `require.paths` on my system looks like this: -`[ '/home/ryan/.node_libraries' ]` +`[ '/home/ryan/.node_modules' ]` That is, when `require('foo')` is called Node looks for: -* 1: `/home/ryan/.node_libraries/foo` -* 2: `/home/ryan/.node_libraries/foo.js` -* 3: `/home/ryan/.node_libraries/foo.node` -* 4: `/home/ryan/.node_libraries/foo/index.js` -* 5: `/home/ryan/.node_libraries/foo/index.node` +* 1: `/home/ryan/.node_modules/foo` +* 2: `/home/ryan/.node_modules/foo.js` +* 3: `/home/ryan/.node_modules/foo.node` +* 4: `/home/ryan/.node_modules/foo/index.js` +* 5: `/home/ryan/.node_modules/foo/index.node` interrupting once a file is found. Files ending in `'.node'` are binary Addon Modules; see 'Addons' below. `'index.js'` allows one to package a module as diff --git a/src/node.js b/src/node.js index 0fe36fce38..2b8fc249a8 100644 --- a/src/node.js +++ b/src/node.js @@ -137,6 +137,7 @@ var module = (function () { // 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")); } defaultPaths.push(path.join(process.execPath, "..", "..", "lib", "node"));