From b2e571ea65a8e4677e5aadfb4e5e71c396134ac7 Mon Sep 17 00:00:00 2001 From: Denys Otrishko Date: Wed, 29 Jan 2020 21:12:59 +0200 Subject: [PATCH] doc: clarify require() OS independence PR-URL: https://github.com/nodejs/node/pull/31571 Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: Rich Trott --- doc/api/modules.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/api/modules.md b/doc/api/modules.md index 3860a7a4d358e5..1cebd32e8147c2 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -618,10 +618,13 @@ Used to import modules, `JSON`, and local files. Modules can be imported from `node_modules`. Local modules and JSON files can be imported using a relative path (e.g. `./`, `./foo`, `./bar/baz`, `../foo`) that will be resolved against the directory named by [`__dirname`][] (if defined) or -the current working directory. +the current working directory. The relative paths of POSIX style are resolved +in an OS independent fashion, meaning that the examples above will work on +Windows in the same way they would on Unix systems. ```js -// Importing a local module: +// Importing a local module with a path relative to the `__dirname` or current +// working directory. (On Windows, this would resolve to .\path\myLocalModule.) const myLocalModule = require('./path/myLocalModule'); // Importing a JSON file: