Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
doc: note ability to require files within packages
Browse files Browse the repository at this point in the history
Adding note to api/modules.markdown about ability to
load arbitrary path from modules from node_module path
by adding reference to path after module name in call
to require()

PR-URL: #7794
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
Reviewed-by: Fedor Indutny <fedor@indutny.com>
Reviewed-by: Timothy J Fontaine <tjfontaine@gmail.com>
  • Loading branch information
sudodoki authored and chrisdickinson committed Nov 10, 2014
1 parent d8a3c4a commit fd22268
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doc/api/modules.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ this order:
This allows programs to localize their dependencies, so that they do not
clash.

You can require specific files or sub modules distributed with a module by
including a path suffix after the module name. For instance
`require('example-module/path/to/file')` would resolve `path/to/file`
relative to where `example-module` is located. The suffixed path follows the
same module resolution semantics.

## Folders as Modules

<!--type=misc-->
Expand Down

0 comments on commit fd22268

Please sign in to comment.