From fd2226894ace84c622b0ca228346da58b20e2949 Mon Sep 17 00:00:00 2001 From: sudodoki Date: Tue, 17 Jun 2014 01:05:58 +0300 Subject: [PATCH] doc: note ability to require files within packages 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: https://github.com/joyent/node/pull/7794 Reviewed-by: Trevor Norris Reviewed-by: Fedor Indutny Reviewed-by: Timothy J Fontaine --- doc/api/modules.markdown | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/api/modules.markdown b/doc/api/modules.markdown index 55d6accdf99e..950d72d891c7 100644 --- a/doc/api/modules.markdown +++ b/doc/api/modules.markdown @@ -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