diff --git a/doc/api/globals.markdown b/doc/api/globals.markdown index 9ee5e48983730a..232d2c4f4a0e23 100644 --- a/doc/api/globals.markdown +++ b/doc/api/globals.markdown @@ -30,6 +30,16 @@ console.log(__dirname); `__dirname` isn't actually a global but rather local to each module. +For instance, given two modules: `a` and `b`, where `b` is a dependency of +`a` and there is a directory structure of: + +* `/Users/mjr/app/a.js` +* `/Users/mjr/app/node_modules/b/b.js` + +References to `__dirname` within `b.js` will return +`/Users/mjr/app/node_modules/b` while references to `__dirname` within `a.js` +will return `/Users/mj/app`. + ## \_\_filename