Skip to content

Commit 0ae5d02

Browse files
jasnellMyles Borins
authored and
Myles Borins
committed
doc: clarify that __dirname is module local
Fixes: #5525 PR-URL: #6018 Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Roman Klauke <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 8bec8aa commit 0ae5d02

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

doc/api/globals.markdown

+10
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ console.log(__dirname);
3030

3131
`__dirname` isn't actually a global but rather local to each module.
3232

33+
For instance, given two modules: `a` and `b`, where `b` is a dependency of
34+
`a` and there is a directory structure of:
35+
36+
* `/Users/mjr/app/a.js`
37+
* `/Users/mjr/app/node_modules/b/b.js`
38+
39+
References to `__dirname` within `b.js` will return
40+
`/Users/mjr/app/node_modules/b` while references to `__dirname` within `a.js`
41+
will return `/Users/mj/app`.
42+
3343
## \_\_filename
3444

3545
<!-- type=var -->

0 commit comments

Comments
 (0)