Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign updocs: add docs to require() #23605
Conversation
nodejs-github-bot
added
doc
module
labels
Oct 12, 2018
jasnell
added
the
code-and-learn
label
Oct 12, 2018
ErickWendel
force-pushed the
ErickWendel:docs/require
branch
from
a3c6917
to
7895992
Oct 12, 2018
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| @@ -552,7 +552,18 @@ added: v0.1.13 | |||
|
|
|||
| * {Function} | |||
|
|
|||
| To require modules. | |||
| Used to import modules, `JSON` and local files. Modules can be imported from `node_modules`. Local modules and JSON files can be imported using the pattern `'./`. | |||
This comment has been minimized.
This comment has been minimized.
lundibundi
Oct 12, 2018
Member
The general rule is to have lines be at most 80 chars, though this can be fixed at landing.
This comment has been minimized.
This comment has been minimized.
|
This probably should be squashed (could be done at landing). |
ErickWendel
force-pushed the
ErickWendel:docs/require
branch
from
a88cac9
to
e908b9e
Oct 12, 2018
This comment has been minimized.
This comment has been minimized.
squashed |
| @@ -552,7 +552,18 @@ added: v0.1.13 | |||
|
|
|||
| * {Function} | |||
|
|
|||
| To require modules. | |||
| Used to import modules, `JSON` and local files. Modules can be imported from `node_modules`. Local modules and JSON files can be imported using the pattern `'./`. | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
ErickWendel
force-pushed the
ErickWendel:docs/require
branch
from
e908b9e
to
18f6f8e
Oct 13, 2018
| @@ -552,7 +552,18 @@ added: v0.1.13 | |||
|
|
|||
| * {Function} | |||
|
|
|||
| To require modules. | |||
| Used to import modules, `JSON` and local files. Modules can be imported from `node_modules`. Local modules and JSON files can be imported using the pattern `'./'`. | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
thefourtheye
Oct 15, 2018
Contributor
Nit: Also, mentioning "relative path" would be better here, maybe with ./ in the brackets.
| Used to import modules, `JSON` and local files. Modules can be imported from `node_modules`. Local modules and JSON files can be imported using the pattern `'./'`. | ||
|
|
||
| ```js | ||
| // importing localModule |
This comment has been minimized.
This comment has been minimized.
| // importing JSON file | ||
| const jsonData = require('./path/filename.json'); | ||
| // importing module from node_modules or Node.js internals |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@ErickWendel .. certainly hope you don't mind, but I went ahead and pushed an additional commit that handled @thefourtheye's nits and added a further clarification. |
| Used to import modules, `JSON` and local files. Modules can be imported from `node_modules`. Local modules and JSON files can be imported using the pattern `'./'`. | ||
| Used to import modules, `JSON`, and local files. Modules can be imported | ||
| from `node_modules`. Local modules and JSON files can be imported using | ||
| a relative path (e.g. `./`, `./foo`, `./bar/baz`, `../foo`) that will be |
This comment has been minimized.
This comment has been minimized.
lundibundi
Oct 16, 2018
Member
Should we perhaps also note that path-resolution is OS independent (given that we are providing examples in Linux/Unix flavor)?
This comment has been minimized.
This comment has been minimized.
BridgeAR
Oct 17, 2018
•
Member
@lundibundi I think that would be a good addition but it could also land in a separate PR?
BridgeAR
added
the
author ready
label
Oct 17, 2018
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Landed in 51cd971 |
Trott
closed this
Oct 24, 2018
This comment has been minimized.
This comment has been minimized.
|
Thanks for the contribution! (If you're interested in other possible contributions to Node.js but don't have a good idea of where to start looking, some ideas are posted at https://www.nodetodo.org/next-steps/.) |
ErickWendel commentedOct 12, 2018
•
edited
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes#23106