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

Commit fd22268

Browse files
sudodokichrisdickinson
authored andcommitted
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: #7794 Reviewed-by: Trevor Norris <[email protected]> Reviewed-by: Fedor Indutny <[email protected]> Reviewed-by: Timothy J Fontaine <[email protected]>
1 parent d8a3c4a commit fd22268

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

doc/api/modules.markdown

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ this order:
175175
This allows programs to localize their dependencies, so that they do not
176176
clash.
177177

178+
You can require specific files or sub modules distributed with a module by
179+
including a path suffix after the module name. For instance
180+
`require('example-module/path/to/file')` would resolve `path/to/file`
181+
relative to where `example-module` is located. The suffixed path follows the
182+
same module resolution semantics.
183+
178184
## Folders as Modules
179185

180186
<!--type=misc-->

0 commit comments

Comments
 (0)