doc: clarify module loading behavior
authorcjihrig <cjihrig@gmail.com>
Thu, 19 Nov 2015 17:05:47 +0000 (12:05 -0500)
committerJames M Snell <jasnell@gmail.com>
Wed, 23 Dec 2015 16:38:33 +0000 (08:38 -0800)
The module loading system will not append node_modules to a
path already ending in node_modules. This used to be documented,
but it was lost.

Fixes: https://github.com/nodejs/node/issues/3873
PR-URL: https://github.com/nodejs/node/pull/3920
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaƫl Zasso <mic.besace@gmail.com>
doc/api/modules.markdown

index e9db1e4..5c1d767 100644 (file)
@@ -339,7 +339,8 @@ example, then `require('./some-library')` would attempt to load:
 If the module identifier passed to `require()` is not a native module,
 and does not begin with `'/'`, `'../'`, or `'./'`, then Node.js starts at the
 parent directory of the current module, and adds `/node_modules`, and
-attempts to load the module from that location.
+attempts to load the module from that location. Node will not append
+`node_modules` to a path already ending in `node_modules`.
 
 If it is not found there, then it moves to the parent directory, and so
 on, until the root of the file system is reached.