Repository: node
Issue: Module resolution is inconsistent across platforms
Labels: module

# Versions

## Windows
```
> node
Welcome to Node.js v15.7.0.
Type ".help" for more information.
> require('os').platform()
'win32'
> require('os').version()
'Windows 10 Pro N'
> require('os').release()
'10.0.19042'
```

## Mac
```
$ node
Welcome to Node.js v15.7.0.
Type ".help" for more information.
> require('os').platform()
'darwin'
> require('os').version()
'Darwin Kernel Version 19.6.0: Tue Nov 10 00:10:30 PST 2020; root:xnu-6153.141.10~1/RELEASE_X86_64'
> require('os').release()
'19.6.0'
```

# Steps to Reproduce

## Windows

- `cd %homepath%`
- `mkdir test\sub\another-sub`
- `cd test`
- Create a file at `sub\another-sub\to-be-imported.js` with any content, possibly empty.
- Create a file at `to-import.js` and give it the following content:
  ```javascript
  require('./sub/another-sub/to-be-imported');
  ```
- One by one, try giving the following module IDs to `require` in `to-import.js` and run `node to-import`. All should work without any errors. Remember to replace `utku` with your username:
  ```
  './sub/another-sub/to-be-imported'
  '.\\sub\\another-sub\\to-be-imported'

  'C:/Users/utku/test/sub/another-sub/to-be-imported'
  'C:\\Users\\utku\\test\\sub\\another-sub\\to-be-imported'

  '/Users/utku/test/sub/another-sub/to-be-imported'
  '\\Users\\utku\\test\\sub\\another-sub\\to-be-imported'

  './sub\\another-sub/to-be-imported'
  '.\\sub/another-sub\\to-be-imported'

  'C:/Users\\utku/test\\sub/another-sub\\to-be-imported'
  'C:\\Users/utku\\test/sub\\another-sub/to-be-imported'

  '/Users\\utku/test\\sub/another-sub\\to-be-imported'
  '\\Users/utku\\test/sub\\another-sub/to-be-imported'
  ```

## Mac

- `cd`
- `mkdir -p test/sub/another-sub`
- `cd test`
- Create a file at `sub/another-sub/to-be-imported.js` with any content, possibly empty.
- Create a file at `to-import.js` and give it the following content:
  ```javascript
  require('./sub/another-sub/to-be-imported');
  ```
- One by one, try giving the following module IDs to `require` in `to-import.js` and run `node to-import`. Only the ones that are marked as "Works" should work. All others should result in a `MODULE_NOT_FOUND` error being thrown. Remember to replace `utku` with your username:
  ```
  // Works
  './sub/another-sub/to-be-imported'
  '.\\sub\\another-sub\\to-be-imported'

  'C:/Users/utku/test/sub/another-sub/to-be-imported'
  'C:\\Users\\utku\\test\\sub\\another-sub\\to-be-imported'

  // Works
  '/Users/utku/test/sub/another-sub/to-be-imported'
  '\\Users\\utku\\test\\sub\\another-sub\\to-be-imported'

  './sub\\another-sub/to-be-imported'
  '.\\sub/another-sub\\to-be-imported'

  'C:/Users\\utku/test\\sub/another-sub\\to-be-imported'
  'C:\\Users/utku\\test/sub\\another-sub/to-be-imported'


  '/Users\\utku/test\\sub/another-sub\\to-be-imported'
  '\\Users/utku\\test/sub\\another-sub/to-be-imported'
  ```
- On the other hand:
  - `mkdir node_modules`
  - `touch node_modules/.\\sub\\another-sub\\to-be-imported.js`
  - Give `'.\\sub\\another-sub\\to-be-imported'` as the argument to `require`. Now `node to-import` should work.
- Another example:
  - `mkdir node_modules/.\\sub`
  - `touch node_modules/.\\sub/another-sub\\to-be-imported.js`
  - Give `'.\\sub/another-sub\\to-be-imported'` as the argument to `require`. Now `node to-import` should work.
- Another example:
  - `touch node_modules/C:\\Users\\utku\\test\\sub\\another-sub\\to-be-imported`
  - Give `'C:\\Users\\utku\\test\\sub\\another-sub\\to-be-imported'` as the argument to `require`. Now `node to-import` should work.

# Expected Behavior
Expected module resolution to be consistent across platforms. The same argument to `require` is interpreted as a "relative path" in one platform, whereas it is interpreted as a "node module" in another one. Also, in one platform, both `/` and `\` characters are interpreted as path separators, whereas only the `/` character in the other one. All of these mean the code that works on one platform might not work on another, meaning the code is not cross-platform.

Even if the current behavior is deemed to be acceptable, at the very least, the [modules API reference](https://nodejs.org/api/modules.html) should be amended to document this discrepancy between Unix and Windows platforms. One example is, in the ["all together" section](https://nodejs.org/api/modules.html#modules_all_together), there is the following:

> ```
> 2. If X begins with '/'
>    a. set Y to be the filesystem root
> 3. If X begins with './' or '/' or '../'
> ```

These are correct for Unix but not for Windows.

# Actual Behavior
There is a discrepancy in module resolution between Unix and Windows platforms.