You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/api/async_context.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,8 @@
6
6
7
7
<!-- source_link=lib/async_hooks.js -->
8
8
9
+
<!-- llm_description=Tracks asynchronous execution context. Enables storing and propagating state across async operations like callbacks and promises. Useful for request tracking, logging, or context management. Provides AsyncLocalStorage for scoped storage and AsyncResource for custom async context binding. -->
10
+
9
11
## Introduction
10
12
11
13
These classes are used to associate state and propagate it throughout
Copy file name to clipboardExpand all lines: doc/api/esm.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
3
3
<!--introduced_in=v8.5.0-->
4
4
5
+
<!-- llm_description=Provides support for ECMAScript modules in Node.js, enabling standards-based module syntax (import/export) and interoperability with CommonJS. -->
Copy file name to clipboardExpand all lines: doc/api/module.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
3
3
<!--introduced_in=v12.20.0-->
4
4
5
+
<!-- llm_description=Provides utilities for interacting with Node.js modules, including support for module creation, resolution, customization hooks, and compile caching. Enables advanced module loading behavior. -->
Copy file name to clipboardExpand all lines: doc/api/packages.md
+68-66Lines changed: 68 additions & 66 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,8 @@
4
4
5
5
<!-- type=misc -->
6
6
7
+
<!-- llm_description=Defines how Node.js resolves and loads modules via fields like type, exports, and imports. Controls module format, entry points, and package encapsulation. -->
8
+
7
9
<!-- YAML
8
10
changes:
9
11
- version:
@@ -61,15 +63,15 @@ Node.js will treat the following as [ES modules][] when passed to `node` as the
61
63
initial input, or when referenced by `import` statements or `import()`
62
64
expressions:
63
65
64
-
* Files with an `.mjs` extension.
66
+
- Files with an `.mjs` extension.
65
67
66
-
* Files with a `.js` extension when the nearest parent `package.json` file
68
+
- Files with a `.js` extension when the nearest parent `package.json` file
67
69
contains a top-level [`"type"`][] field with a value of `"module"`.
68
70
69
-
* Strings passed in as an argument to `--eval`, or piped to `node` via `STDIN`,
71
+
- Strings passed in as an argument to `--eval`, or piped to `node` via `STDIN`,
70
72
with the flag `--input-type=module`.
71
73
72
-
* Code containing syntax only successfully parsed as [ES modules][], such as
74
+
- Code containing syntax only successfully parsed as [ES modules][], such as
73
75
`import` or `export` statements or `import.meta`, with no explicit marker of
74
76
how it should be interpreted. Explicit markers are `.mjs` or `.cjs`
75
77
extensions, `package.json``"type"` fields with either `"module"` or
@@ -81,15 +83,15 @@ Node.js will treat the following as [CommonJS][] when passed to `node` as the
81
83
initial input, or when referenced by `import` statements or `import()`
82
84
expressions:
83
85
84
-
* Files with a `.cjs` extension.
86
+
- Files with a `.cjs` extension.
85
87
86
-
* Files with a `.js` extension when the nearest parent `package.json` file
88
+
- Files with a `.js` extension when the nearest parent `package.json` file
87
89
contains a top-level field [`"type"`][] with a value of `"commonjs"`.
88
90
89
-
* Strings passed in as an argument to `--eval` or `--print`, or piped to `node`
91
+
- Strings passed in as an argument to `--eval` or `--print`, or piped to `node`
90
92
via `STDIN`, with the flag `--input-type=commonjs`.
91
93
92
-
* Files with a `.js` extension with no parent `package.json` file or where the
94
+
- Files with a `.js` extension with no parent `package.json` file or where the
93
95
nearest parent `package.json` file lacks a `type` field, and where the code
94
96
can evaluate successfully as CommonJS. In other words, Node.js tries to run
95
97
such "ambiguous" files as CommonJS first, and will retry evaluating them as ES
@@ -127,19 +129,19 @@ as an ES module.
127
129
128
130
Ambiguous input is defined as:
129
131
130
-
* Files with a `.js` extension or no extension; and either no controlling
132
+
- Files with a `.js` extension or no extension; and either no controlling
131
133
`package.json` file or one that lacks a `type` field.
132
-
* String input (`--eval` or `STDIN`) when `--input-type`is not specified.
134
+
- String input (`--eval` or `STDIN`) when `--input-type`is not specified.
133
135
134
136
ES module syntax is defined as syntax that would throw when evaluated as
135
137
CommonJS. This includes the following:
136
138
137
-
*`import` statements (but _not_`import()` expressions, which are valid in
139
+
-`import` statements (but _not_`import()` expressions, which are valid in
138
140
CommonJS).
139
-
*`export` statements.
140
-
*`import.meta` references.
141
-
*`await` at the top level of a module.
142
-
* Lexical redeclarations of the CommonJS wrapper variables (`require`, `module`,
141
+
-`export` statements.
142
+
-`import.meta` references.
143
+
-`await` at the top level of a module.
144
+
- Lexical redeclarations of the CommonJS wrapper variables (`require`, `module`,
143
145
`exports`, `__dirname`, `__filename`).
144
146
145
147
### Modules loaders
@@ -148,36 +150,36 @@ Node.js has two systems for resolving a specifier and loading modules.
148
150
149
151
There is the CommonJS module loader:
150
152
151
-
* It is fully synchronous.
152
-
* It is responsible for handling `require()` calls.
153
-
* It is monkey patchable.
154
-
* It supports [folders as modules][].
155
-
* When resolving a specifier, if no exact match is found, it will try to add
153
+
- It is fully synchronous.
154
+
- It is responsible for handling `require()` calls.
155
+
- It is monkey patchable.
156
+
- It supports [folders as modules][].
157
+
- When resolving a specifier, if no exact match is found, it will try to add
156
158
extensions (`.js`, `.json`, and finally `.node`) and then attempt to resolve
157
159
[folders as modules][].
158
-
* It treats `.json` as JSON text files.
159
-
*`.node` files are interpreted as compiled addon modules loaded with
160
+
- It treats `.json` as JSON text files.
161
+
-`.node` files are interpreted as compiled addon modules loaded with
160
162
`process.dlopen()`.
161
-
* It treats all files that lack `.json` or `.node` extensions as JavaScript
163
+
- It treats all files that lack `.json` or `.node` extensions as JavaScript
162
164
text files.
163
-
* It can only be used to [load ECMAScript modules from CommonJS modules][] if
165
+
- It can only be used to [load ECMAScript modules from CommonJS modules][] if
164
166
the module graph is synchronous (that contains no top-level `await`).
165
167
When used to load a JavaScript text file that is not an ECMAScript module,
166
168
the file will be loaded as a CommonJS module.
167
169
168
170
There is the ECMAScript module loader:
169
171
170
-
* It is asynchronous, unless it's being used to load modules for `require()`.
171
-
* It is responsible for handling `import` statements and `import()` expressions.
172
-
* It is not monkey patchable, can be customized using [loader hooks][].
173
-
* It does not support folders as modules, directory indexes (e.g.
172
+
- It is asynchronous, unless it's being used to load modules for `require()`.
173
+
- It is responsible for handling `import` statements and `import()` expressions.
174
+
- It is not monkey patchable, can be customized using [loader hooks][].
175
+
- It does not support folders as modules, directory indexes (e.g.
174
176
`'./startup/index.js'`) must be fully specified.
175
-
* It does no extension searching. A file extension must be provided
177
+
- It does no extension searching. A file extension must be provided
176
178
when the specifier is a relative or absolute file URL.
177
-
* It can load JSON modules, but an import type attribute is required.
178
-
* It accepts only `.js`, `.mjs`, and `.cjs` extensions for JavaScript text
179
+
- It can load JSON modules, but an import type attribute is required.
180
+
- It accepts only `.js`, `.mjs`, and `.cjs` extensions for JavaScript text
179
181
files.
180
-
* It can be used to load JavaScript CommonJS modules. Such modules
182
+
- It can be used to load JavaScript CommonJS modules. Such modules
181
183
are passed through the `cjs-module-lexer` to try to identify named exports,
182
184
which are available if they can be determined through static analysis.
183
185
Imported CommonJS modules have their URLs converted to absolute
Copy file name to clipboardExpand all lines: doc/api/typescript.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,8 @@ changes:
15
15
16
16
<!--introduced_in=v22.6.0-->
17
17
18
+
<!-- llm_description=Provides lightweight TypeScript support in Node.js via type stripping. Enables execution of .ts files without type checking or full compiler features. -->
0 commit comments