Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9679e2d

Browse filesBrowse files
jasnellMyles Borins
authored andcommitted
doc: clarify that __dirname is module local
Fixes: #5525 PR-URL: #6018 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Roman Klauke <romaaan.git@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent dfe9e15 commit 9679e2d
Copy full SHA for 9679e2d

File tree

Expand file treeCollapse file tree

1 file changed

+10
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-0
lines changed
Open diff view settings
Collapse file

‎doc/api/globals.markdown‎

Copy file name to clipboardExpand all lines: doc/api/globals.markdown
+10Lines changed: 10 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.