-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc: include global node_modules in require.resolve description #20534
Conversation
doc/api/modules.md
Outdated
these paths is used as a starting point for the module resolution algorithm, | ||
meaning that the `node_modules` hierarchy is checked from this location. | ||
paths are used instead of the default resolution paths, with the exception | ||
of global folders like ~/.node_modules, which are always included. Note that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: ~/.node_modules
-> `~/.node_modules`
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(If so, this line will need rewrapping at 80 characters.)
LGTM with the comments addressed. |
Looks like GitHub's web interface no longer fully works on IOS 10 so I can't properly review this to request changes. Please could you rename cc @nodejs/modules |
a72eab6
to
7967eca
Compare
Updated. |
Node.js Collaborators, please, add 👍 here if you approve fast-tracking. |
doc/api/modules.md
Outdated
2. for each DIR in DIRS: | ||
a. LOAD_AS_FILE(DIR/X) | ||
b. LOAD_AS_DIRECTORY(DIR/X) | ||
|
||
NODE_MODULES_PATHS(START) | ||
1. let PARTS = path split(START) | ||
2. let I = count of PARTS - 1 | ||
3. let DIRS = [] | ||
3. let DIRS = [ GLOBAL_FOLDERS ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The term “GLOBAL_FOLDERS” doesn’t appear to be defined anywhere; if you mean the list in line 424, could you alter that list as well to use this identical term?
Ideally, this term would also link down to that section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ljharb What would be the best way to capture this? The main heading is regarding "loading from the global folders." Would it make sense to say Additionally, Node.js will search in the following global folders:
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even just a sentence in the below section like “This list of GLOBAL_FOLDERS:” or something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’d be cool if the mention in the algorithm itself could also be linked.
b295820
to
354be97
Compare
354be97
to
263ad12
Compare
doc/api/modules.md
Outdated
2. for each DIR in DIRS: | ||
a. LOAD_AS_FILE(DIR/X) | ||
b. LOAD_AS_DIRECTORY(DIR/X) | ||
|
||
NODE_MODULES_PATHS(START) | ||
1. let PARTS = path split(START) | ||
2. let I = count of PARTS - 1 | ||
3. let DIRS = [] | ||
3. let DIRS = [GLOBAL_FOLDERS](#modules_loading_from_the_global_folders) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this link render on the website? On github it's not.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I misunderstood the note.
doc/api/modules.md
Outdated
meaning that the `node_modules` hierarchy is checked from this location. | ||
paths are used instead of the default resolution paths, with the exception | ||
of [GLOBAL_FOLDERS](#modules_loading_from_the_global_folders) like | ||
`~/.node_modules`, which are always included. Note that each of these paths |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$HOME/.node_modules
should be preferred, tild is from bash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$HOME/.node_modules
would also be consistent with the list in the Loading from the global folders
section.
doc/api/modules.md
Outdated
these paths is used as a starting point for the module resolution algorithm, | ||
meaning that the `node_modules` hierarchy is checked from this location. | ||
paths are used instead of the default resolution paths, with the exception | ||
of [GLOBAL_FOLDERS](#modules_loading_from_the_global_folders) like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the link #modules_loading_from_the_global_folders is used twice in the document, it can be moved to bottom of the page as follows:
2390fa1
to
4b6bf5c
Compare
This comment has been minimized.
This comment has been minimized.
@xtuc's comment still stands, the change doesn't render as a link in GitHub: https://github.com/musgravejw/node/blob/4b6bf5cca73c211007d99344522fb91c6b9668bf/doc/api/modules.md#all-together |
Since it's in a preformatted block, I don't think that's possible. Either way, as long as I can "find in page" for "GLOBAL_FOLDERS", it's good, and i think i'd personally rather have the website be more usable with a link than have the markdown be less messy by omitting the link. |
Yes, sorry, I'missed that this is a code block. |
@vsemozhetbyt #20534 (review) is not addressed yet |
4b6bf5c
to
75924f6
Compare
|
75924f6
to
c7e33fe
Compare
doc/api/modules.md
Outdated
`~/.node_modules`, which are always included. Note that each of these paths | ||
is used as a starting point for the module resolution algorithm, meaning | ||
that the `node_modules` hierarchy is checked from this location. | ||
of [GLOBAL_FOLDERS][] like `$HOME/.node_modules`, which are always |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: trailing space, but this can be fixed on landing)
2. for each DIR in DIRS: | ||
a. LOAD_AS_FILE(DIR/X) | ||
b. LOAD_AS_DIRECTORY(DIR/X) | ||
|
||
NODE_MODULES_PATHS(START) | ||
1. let PARTS = path split(START) | ||
2. let I = count of PARTS - 1 | ||
3. let DIRS = [] | ||
3. let DIRS = [GLOBAL_FOLDERS] |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Landed in 6fd8022 (with a tiny fix: insert bottom reference in ASCII sort order). Thank you! |
Closes: #18926
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes