Skip to content

Commit b2e571e

Browse files
lundibundicodebytere
authored andcommitted
doc: clarify require() OS independence
PR-URL: #31571 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent ff1e5e0 commit b2e571e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

doc/api/modules.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,10 +618,13 @@ Used to import modules, `JSON`, and local files. Modules can be imported
618618
from `node_modules`. Local modules and JSON files can be imported using
619619
a relative path (e.g. `./`, `./foo`, `./bar/baz`, `../foo`) that will be
620620
resolved against the directory named by [`__dirname`][] (if defined) or
621-
the current working directory.
621+
the current working directory. The relative paths of POSIX style are resolved
622+
in an OS independent fashion, meaning that the examples above will work on
623+
Windows in the same way they would on Unix systems.
622624

623625
```js
624-
// Importing a local module:
626+
// Importing a local module with a path relative to the `__dirname` or current
627+
// working directory. (On Windows, this would resolve to .\path\myLocalModule.)
625628
const myLocalModule = require('./path/myLocalModule');
626629

627630
// Importing a JSON file:

0 commit comments

Comments
 (0)