doc: small clarifications to modules.markdown

per: https://github.com/joyent/node/pull/8708

A modified version of the original PR submitted by @builtbylane.

Reviewed By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/2378
This commit is contained in:
James M Snell authored and Rod Vagg committed 2015-08-26 21:18:52 +10:00
1 parent c888985591
commit 1d4ea609db
1 file changed
+9 -6
+9 -6
View File
@@ -121,6 +121,8 @@ io.js has several modules compiled into the binary. These modules are
described in greater detail elsewhere in this documentation.
The core modules are defined in io.js's source in the `lib/` folder.
The core modules are defined within io.js's source and are located in the
`lib/` folder.
Core modules are always preferentially loaded if their identifier is
passed to `require()`. For instance, `require('http')` will always
@@ -131,22 +133,23 @@ return the built in HTTP module, even if there is a file by that name.
<!--type=misc-->
If the exact filename is not found, then io.js will attempt to load the
required filename with the added extension of `.js`, `.json`, and then `.node`.
required filename with the added extensions: `.js`, `.json`, and finally
`.node`.
`.js` files are interpreted as JavaScript text files, and `.json` files are
parsed as JSON text files. `.node` files are interpreted as compiled addon
modules loaded with `dlopen`.
A module prefixed with `'/'` is an absolute path to the file. For
A required module prefixed with `'/'` is an absolute path to the file. For
example, `require('/home/marco/foo.js')` will load the file at
`/home/marco/foo.js`.
A module prefixed with `'./'` is relative to the file calling `require()`.
That is, `circle.js` must be in the same directory as `foo.js` for
A required module prefixed with `'./'` is relative to the file calling
`require()`. That is, `circle.js` must be in the same directory as `foo.js` for
`require('./circle')` to find it.
Without a leading '/', './', or '../' to indicate a file, the module is either a
core module or is loaded from a `node_modules` folder.
Without a leading '/', './', or '../' to indicate a file, the module must
either be a core module or is loaded from a `node_modules` folder.
If the given path does not exist, `require()` will throw an Error with its
`code` property set to `'MODULE_NOT_FOUND'`.