diff options
author | James M Snell <jasnell@gmail.com> | 2016-04-01 23:06:28 -0700 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2016-04-02 16:37:52 -0700 |
commit | c06824b4b7a82860ff5c92c98bc846d250caab7e (patch) | |
tree | 0a3c5405d41dd405286734982f5b6881bad492fc | |
parent | 33003a52d2f3f7bedf393b2484c40968cbd7f02b (diff) | |
download | node-new-c06824b4b7a82860ff5c92c98bc846d250caab7e.tar.gz |
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 <thechargingvolcano@gmail.com>
Reviewed-By: Roman Klauke <romaaan.git@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
-rw-r--r-- | doc/api/globals.markdown | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/doc/api/globals.markdown b/doc/api/globals.markdown index 94fc332f94..1e2e0562bd 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 <!-- type=var --> |