From 0ae5d027c676182e4e3c6745e05e5ff240ee3987 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Fri, 1 Apr 2016 23:06:28 -0700 Subject: [PATCH] doc: clarify that __dirname is module local Fixes: https://github.com/nodejs/node/issues/5525 PR-URL: https://github.com/nodejs/node/pull/6018 Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Roman Klauke Reviewed-By: Colin Ihrig --- doc/api/globals.markdown | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/api/globals.markdown b/doc/api/globals.markdown index 94fc332f94ac32..1bee7d0cf988c2 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