diff --git a/benchmark/http_simple.js b/benchmark/http_simple.js index 8974af647c..43435ad5bc 100644 --- a/benchmark/http_simple.js +++ b/benchmark/http_simple.js @@ -1,5 +1,5 @@ libDir = node.path.join(node.path.dirname(__filename), "../lib"); -node.libraryPaths.unshift(libDir); +require.paths.unshift(libDir); node.mixin(require("/utils.js")); http = require("/http.js"); diff --git a/benchmark/process_loop.js b/benchmark/process_loop.js index 6f4d07ea94..494074a9cf 100644 --- a/benchmark/process_loop.js +++ b/benchmark/process_loop.js @@ -1,5 +1,5 @@ libDir = node.path.join(node.path.dirname(__filename), "../lib"); -node.libraryPaths.unshift(libDir); +require.paths.unshift(libDir); node.mixin(require("/utils.js")); function next (i) { if (i <= 0) return; diff --git a/benchmark/run.js b/benchmark/run.js index 6379a16fe2..965022b3f9 100644 --- a/benchmark/run.js +++ b/benchmark/run.js @@ -1,5 +1,5 @@ libDir = node.path.join(node.path.dirname(__filename), "../lib"); -node.libraryPaths.unshift(libDir); +require.paths.unshift(libDir); node.mixin(require("/utils.js")); var benchmarks = [ "static_http_server.js" , "timers.js" diff --git a/benchmark/static_http_server.js b/benchmark/static_http_server.js index 3ce04997f0..1866051106 100644 --- a/benchmark/static_http_server.js +++ b/benchmark/static_http_server.js @@ -1,5 +1,5 @@ libDir = node.path.join(node.path.dirname(__filename), "../lib"); -node.libraryPaths.unshift(libDir); +require.paths.unshift(libDir); http = require("/http.js"); var concurrency = 30; var port = 8000; diff --git a/doc/api.txt b/doc/api.txt index 4bb146feb8..0f0cfd64da 100644 --- a/doc/api.txt +++ b/doc/api.txt @@ -73,7 +73,7 @@ more information. +require(path)+ :: See the modules section. -+node.libraryPaths+ :: ++require.paths+ :: The search path for absolute path arguments to +require()+. +node.mixin([deep], target, object1, [objectN])+ :: @@ -369,7 +369,7 @@ puts("The area of a cirlce of radius 4 is " + area(4)); When an absolute path is given to +require()+, like +require("/mjsunit.js")+ the module is searched for in the -+node.libraryPaths+ array. +node.libraryPaths+ on my system looks like this: ++require.paths+ array. +require.paths+ on my system looks like this: ---------------------------------------- [ "/home/ryan/.node_libraries" @@ -382,7 +382,7 @@ That is, first Node looks for +"/home/ryan/.node_libraries/mjsunit.js"+ and then for +"/home/ryan/local/node/lib/node_libraries/mjsunit.js"+. If not found, it finally looks for +"/mjsunit.js"+ (in the root directory). -+node.libraryPaths+ can be modified at runtime by simply unshifting new ++require.paths+ can be modified at runtime by simply unshifting new paths on to it and at startup with the +NODE_LIBRARY_PATHS+ environmental variable (which should be a list of paths, colon separated). diff --git a/src/node.js b/src/node.js index 1b3923d2a1..dc55624ba9 100644 --- a/src/node.js +++ b/src/node.js @@ -294,6 +294,7 @@ node.Module.prototype.loadScript = function (loadPromise) { return requireAsync(url).wait(); } + require.paths = node.libraryPaths; require.async = requireAsync; // create wrapper function diff --git a/test/mjsunit/common.js b/test/mjsunit/common.js index 53338ab0c3..808f676e81 100644 --- a/test/mjsunit/common.js +++ b/test/mjsunit/common.js @@ -2,7 +2,7 @@ exports.testDir = node.path.dirname(__filename); exports.fixturesDir = node.path.join(exports.testDir, "fixtures"); exports.libDir = node.path.join(exports.testDir, "../../lib"); -node.libraryPaths.unshift(exports.libDir); +require.paths.unshift(exports.libDir); var mjsunit = require("/mjsunit.js"); var utils = require("/utils.js"); diff --git a/test/mjsunit/test-buffered-file.js b/test/mjsunit/test-buffered-file.js index a27a3a714c..23502b554b 100644 --- a/test/mjsunit/test-buffered-file.js +++ b/test/mjsunit/test-buffered-file.js @@ -3,7 +3,7 @@ node.mixin(require("common.js")); var testTxt = node.path.join(fixturesDir, "test.txt"); var libDir = node.path.join(testDir, "../../lib"); -node.libraryPaths.unshift(libDir); +require.paths.unshift(libDir); node.mixin(require("/file.js")); var fileUnlinked = false;