-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,15 +175,15 @@ LOAD_AS_DIRECTORY(X) | |
2. LOAD_INDEX(X) | ||
|
||
LOAD_NODE_MODULES(X, START) | ||
1. let DIRS=NODE_MODULES_PATHS(START) | ||
1. let DIRS = NODE_MODULES_PATHS(START) | ||
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) | ||
4. while I >= 0, | ||
a. if PARTS[I] = "node_modules" CONTINUE | ||
b. DIR = path join(PARTS[0 .. I] + "node_modules") | ||
|
@@ -419,7 +419,7 @@ when people are unaware that `NODE_PATH` must be set. Sometimes a | |
module's dependencies change, causing a different version (or even a | ||
different module) to be loaded as the `NODE_PATH` is searched. | ||
|
||
Additionally, Node.js will search in the following locations: | ||
Additionally, Node.js will search in the following list of GLOBAL_FOLDERS: | ||
|
||
* 1: `$HOME/.node_modules` | ||
* 2: `$HOME/.node_libraries` | ||
|
@@ -649,9 +649,11 @@ changes: | |
* `request` {string} The module path to resolve. | ||
* `options` {Object} | ||
* `paths` {string[]} Paths to resolve module location from. If present, these | ||
paths are used instead of the default resolution paths. 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. | ||
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 commentThe 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: |
||
`~/.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 commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
is used as a starting point for the module resolution algorithm, meaning | ||
that the `node_modules` hierarchy is checked from this location. | ||
* Returns: {string} | ||
|
||
Use the internal `require()` machinery to look up the location of a module, | ||
|
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.
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.
It seems not up-to-date, or is it just me?
This comment was marked as off-topic.
Sorry, something went wrong.
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.