@types/node 24.12.0 → 25.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- node v24.12/README.md → node/README.md +2 -2
- node v24.12/assert/strict.d.ts → node/assert/strict.d.ts +5 -11
- node v24.12/assert.d.ts → node/assert.d.ts +11 -171
- node v24.12/async_hooks.d.ts → node/async_hooks.d.ts +8 -8
- node v24.12/buffer.buffer.d.ts → node/buffer.buffer.d.ts +1 -7
- node v24.12/buffer.d.ts → node/buffer.d.ts +44 -168
- node v24.12/child_process.d.ts → node/child_process.d.ts +21 -64
- node/cluster.d.ts +486 -0
- node/console.d.ts +151 -0
- node v24.12/constants.d.ts → node/constants.d.ts +3 -4
- node v24.12/crypto.d.ts → node/crypto.d.ts +287 -1639
- node v24.12/dgram.d.ts → node/dgram.d.ts +15 -51
- node v24.12/diagnostics_channel.d.ts → node/diagnostics_channel.d.ts +4 -4
- node v24.12/dns/promises.d.ts → node/dns/promises.d.ts +3 -3
- node v24.12/dns.d.ts → node/dns.d.ts +131 -132
- node v24.12/domain.d.ts → node/domain.d.ts +13 -17
- node v24.12/events.d.ts → node/events.d.ts +866 -795
- node v24.12/fs/promises.d.ts → node/fs/promises.d.ts +7 -8
- node v24.12/fs.d.ts → node/fs.d.ts +419 -455
- node v24.12/globals.d.ts → node/globals.d.ts +6 -26
- node/globals.typedarray.d.ts +101 -0
- node v24.12/http.d.ts → node/http.d.ts +310 -276
- node v24.12/http2.d.ts → node/http2.d.ts +528 -804
- node v24.12/https.d.ts → node/https.d.ts +63 -243
- node v24.12/index.d.ts → node/index.d.ts +15 -1
- node/inspector/promises.d.ts +41 -0
- node v24.12/inspector.d.ts → node/inspector.d.ts +42 -50
- node v24.12/inspector.generated.d.ts → node/inspector.generated.d.ts +572 -417
- node v24.12/module.d.ts → node/module.d.ts +47 -195
- node v24.12/net.d.ts → node/net.d.ts +68 -189
- node v24.12/os.d.ts → node/os.d.ts +6 -6
- node v24.12/package.json → node/package.json +3 -3
- node/path/posix.d.ts +8 -0
- node/path/win32.d.ts +8 -0
- node/path.d.ts +187 -0
- node/perf_hooks.d.ts +643 -0
- node v24.12/process.d.ts → node/process.d.ts +219 -127
- node v24.12/punycode.d.ts → node/punycode.d.ts +5 -5
- node v24.12/querystring.d.ts → node/querystring.d.ts +4 -4
- node/quic.d.ts +910 -0
- node v24.12/readline/promises.d.ts → node/readline/promises.d.ts +3 -3
- node v24.12/readline.d.ts → node/readline.d.ts +68 -120
- node v24.12/repl.d.ts → node/repl.d.ts +75 -98
- node v24.12/sea.d.ts → node/sea.d.ts +1 -1
- node v24.12/sqlite.d.ts → node/sqlite.d.ts +137 -30
- node v24.12/stream/consumers.d.ts → node/stream/consumers.d.ts +10 -10
- node/stream/promises.d.ts +211 -0
- node/stream/web.d.ts +296 -0
- node v24.12/stream.d.ts → node/stream.d.ts +565 -478
- node v24.12/string_decoder.d.ts → node/string_decoder.d.ts +4 -4
- node/test/reporters.d.ts +96 -0
- node v24.12/test.d.ts → node/test.d.ts +134 -199
- node v24.12/timers/promises.d.ts → node/timers/promises.d.ts +4 -4
- node v24.12/timers.d.ts → node/timers.d.ts +4 -130
- node v24.12/tls.d.ts → node/tls.d.ts +109 -179
- node v24.12/trace_events.d.ts → node/trace_events.d.ts +9 -9
- node v24.12/ts5.6/buffer.buffer.d.ts → node/ts5.6/buffer.buffer.d.ts +1 -7
- node v24.12/ts5.6/index.d.ts → node/ts5.6/index.d.ts +15 -1
- node v24.12/ts5.7/index.d.ts → node/ts5.7/index.d.ts +15 -1
- node v24.12/tty.d.ts → node/tty.d.ts +58 -16
- node/url.d.ts +541 -0
- node/util/types.d.ts +558 -0
- node v24.12/util.d.ts → node/util.d.ts +150 -796
- node v24.12/v8.d.ts → node/v8.d.ts +31 -21
- node v24.12/vm.d.ts → node/vm.d.ts +43 -30
- node v24.12/wasi.d.ts → node/wasi.d.ts +4 -4
- node v24.12/web-globals/abortcontroller.d.ts → node/web-globals/abortcontroller.d.ts +27 -2
- node/web-globals/blob.d.ts +23 -0
- node/web-globals/console.d.ts +9 -0
- node v24.12/web-globals/crypto.d.ts → node/web-globals/crypto.d.ts +7 -0
- node/web-globals/encoding.d.ts +11 -0
- node v24.12/web-globals/events.d.ts → node/web-globals/events.d.ts +9 -0
- node v24.12/web-globals/fetch.d.ts → node/web-globals/fetch.d.ts +7 -0
- node/web-globals/importmeta.d.ts +13 -0
- node/web-globals/messaging.d.ts +23 -0
- node/web-globals/performance.d.ts +45 -0
- node/web-globals/streams.d.ts +115 -0
- node/web-globals/timers.d.ts +44 -0
- node/web-globals/url.d.ts +24 -0
- node v24.12/worker_threads.d.ts → node/worker_threads.d.ts +186 -363
- node v24.12/zlib.d.ts → node/zlib.d.ts +8 -71
- node v24.12/cluster.d.ts +0 -578
- node v24.12/console.d.ts +0 -453
- node v24.12/globals.typedarray.d.ts +0 -41
- node v24.12/path.d.ts +0 -200
- node v24.12/perf_hooks.d.ts +0 -1042
- node v24.12/stream/promises.d.ts +0 -90
- node v24.12/stream/web.d.ts +0 -573
- node v24.12/url.d.ts +0 -1057
- node v24.12/web-globals/streams.d.ts +0 -22
- {node v24.12 → node}/LICENSE +0 -0
- {node v24.12 → node}/compatibility/iterators.d.ts +0 -0
- {node v24.12 → node}/ts5.6/compatibility/float16array.d.ts +0 -0
- {node v24.12 → node}/ts5.6/globals.typedarray.d.ts +0 -0
- {node v24.12 → node}/ts5.7/compatibility/float16array.d.ts +0 -0
- {node v24.12 → node}/web-globals/domexception.d.ts +0 -0
- {node v24.12 → node}/web-globals/navigator.d.ts +0 -0
- {node v24.12 → node}/web-globals/storage.d.ts +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @since v0.3.7
|
|
3
3
|
*/
|
|
4
|
-
declare module "module" {
|
|
4
|
+
declare module "node:module" {
|
|
5
5
|
import { URL } from "node:url";
|
|
6
6
|
class Module {
|
|
7
7
|
constructor(id: string, parent?: Module);
|
|
@@ -30,7 +30,7 @@ declare module "module" {
|
|
|
30
30
|
/**
|
|
31
31
|
* The following constants are returned as the `status` field in the object returned by
|
|
32
32
|
* {@link enableCompileCache} to indicate the result of the attempt to enable the
|
|
33
|
-
* [module compile cache](https://nodejs.org/docs/latest-
|
|
33
|
+
* [module compile cache](https://nodejs.org/docs/latest-v25.x/api/module.html#module-compile-cache).
|
|
34
34
|
* @since v22.8.0
|
|
35
35
|
*/
|
|
36
36
|
namespace compileCacheStatus {
|
|
@@ -62,6 +62,24 @@ declare module "module" {
|
|
|
62
62
|
const DISABLED: number;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
+
interface EnableCompileCacheOptions {
|
|
66
|
+
/**
|
|
67
|
+
* Optional. Directory to store the compile cache. If not specified,
|
|
68
|
+
* the directory specified by the `NODE_COMPILE_CACHE=dir` environment variable
|
|
69
|
+
* will be used if it's set, or `path.join(os.tmpdir(), 'node-compile-cache')`
|
|
70
|
+
* otherwise.
|
|
71
|
+
* @since v25.0.0
|
|
72
|
+
*/
|
|
73
|
+
directory?: string | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Optional. If `true`, enables portable compile cache so that
|
|
76
|
+
* the cache can be reused even if the project directory is moved. This is a best-effort
|
|
77
|
+
* feature. If not specified, it will depend on whether the environment variable
|
|
78
|
+
* `NODE_COMPILE_CACHE_PORTABLE=1` is set.
|
|
79
|
+
* @since v25.0.0
|
|
80
|
+
*/
|
|
81
|
+
portable?: boolean | undefined;
|
|
82
|
+
}
|
|
65
83
|
interface EnableCompileCacheResult {
|
|
66
84
|
/**
|
|
67
85
|
* One of the {@link constants.compileCacheStatus}
|
|
@@ -80,50 +98,34 @@ declare module "module" {
|
|
|
80
98
|
*/
|
|
81
99
|
directory?: string;
|
|
82
100
|
}
|
|
83
|
-
interface EnableCompileCacheOptions {
|
|
84
|
-
/**
|
|
85
|
-
* Optional. Directory to store the compile cache. If not specified, the directory specified by
|
|
86
|
-
* the [`NODE_COMPILE_CACHE=dir`](https://nodejs.org/docs/latest-v24.x/api/cli.html#node_compile_cachedir)
|
|
87
|
-
* environment variable will be used if it's set, or `path.join(os.tmpdir(), 'node-compile-cache')` otherwise.
|
|
88
|
-
* @since v24.12.0
|
|
89
|
-
*/
|
|
90
|
-
directory?: string | undefined;
|
|
91
|
-
/**
|
|
92
|
-
* Optional. If `true`, enables portable compile cache so that the cache can be reused even if the project directory
|
|
93
|
-
* is moved. This is a best-effort feature. If not specified, it will depend on whether the environment variable
|
|
94
|
-
* [NODE_COMPILE_CACHE_PORTABLE=1](https://nodejs.org/docs/latest-v24.x/api/cli.html#node_compile_cache_portable1) is set.
|
|
95
|
-
* @since v24.12.0
|
|
96
|
-
*/
|
|
97
|
-
portable?: boolean | undefined;
|
|
98
|
-
}
|
|
99
101
|
/**
|
|
100
|
-
* Enable [module compile cache](https://nodejs.org/docs/latest-
|
|
102
|
+
* Enable [module compile cache](https://nodejs.org/docs/latest-v25.x/api/module.html#module-compile-cache)
|
|
101
103
|
* in the current Node.js instance.
|
|
102
104
|
*
|
|
103
|
-
* For general use cases, it's recommended to call `module.enableCompileCache()` without
|
|
104
|
-
* `options.directory`, so that the directory can be overridden by the
|
|
105
|
-
* variable when necessary.
|
|
105
|
+
* For general use cases, it's recommended to call `module.enableCompileCache()` without
|
|
106
|
+
* specifying the `options.directory`, so that the directory can be overridden by the
|
|
107
|
+
* `NODE_COMPILE_CACHE` environment variable when necessary.
|
|
106
108
|
*
|
|
107
|
-
* Since compile cache is supposed to be a optimization that is not mission critical, this
|
|
108
|
-
* designed to not throw any exception when the compile cache cannot be enabled.
|
|
109
|
-
* an object containing an error message in the `message` field to
|
|
110
|
-
* enabled successfully, the `directory` field in the
|
|
111
|
-
*
|
|
112
|
-
* `
|
|
113
|
-
*
|
|
109
|
+
* Since compile cache is supposed to be a optimization that is not mission critical, this
|
|
110
|
+
* method is designed to not throw any exception when the compile cache cannot be enabled.
|
|
111
|
+
* Instead, it will return an object containing an error message in the `message` field to
|
|
112
|
+
* aid debugging. If compile cache is enabled successfully, the `directory` field in the
|
|
113
|
+
* returned object contains the path to the directory where the compile cache is stored. The
|
|
114
|
+
* `status` field in the returned object would be one of the `module.constants.compileCacheStatus`
|
|
115
|
+
* values to indicate the result of the attempt to enable the
|
|
116
|
+
* [module compile cache](https://nodejs.org/docs/latest-v25.x/api/module.html#module-compile-cache).
|
|
114
117
|
*
|
|
115
118
|
* This method only affects the current Node.js instance. To enable it in child worker threads,
|
|
116
119
|
* either call this method in child worker threads too, or set the
|
|
117
120
|
* `process.env.NODE_COMPILE_CACHE` value to compile cache directory so the behavior can
|
|
118
121
|
* be inherited into the child workers. The directory can be obtained either from the
|
|
119
|
-
* `directory` field returned by this method, or with {@link getCompileCacheDir
|
|
122
|
+
* `directory` field returned by this method, or with {@link getCompileCacheDir}.
|
|
120
123
|
* @since v22.8.0
|
|
121
124
|
* @param options Optional. If a string is passed, it is considered to be `options.directory`.
|
|
122
|
-
* will be stored/retrieved.
|
|
123
125
|
*/
|
|
124
126
|
function enableCompileCache(options?: string | EnableCompileCacheOptions): EnableCompileCacheResult;
|
|
125
127
|
/**
|
|
126
|
-
* Flush the [module compile cache](https://nodejs.org/docs/latest-
|
|
128
|
+
* Flush the [module compile cache](https://nodejs.org/docs/latest-v25.x/api/module.html#module-compile-cache)
|
|
127
129
|
* accumulated from modules already loaded
|
|
128
130
|
* in the current Node.js instance to disk. This returns after all the flushing
|
|
129
131
|
* file system operations come to an end, no matter they succeed or not. If there
|
|
@@ -134,7 +136,7 @@ declare module "module" {
|
|
|
134
136
|
function flushCompileCache(): void;
|
|
135
137
|
/**
|
|
136
138
|
* @since v22.8.0
|
|
137
|
-
* @return Path to the [module compile cache](https://nodejs.org/docs/latest-
|
|
139
|
+
* @return Path to the [module compile cache](https://nodejs.org/docs/latest-v25.x/api/module.html#module-compile-cache)
|
|
138
140
|
* directory if it is enabled, or `undefined` otherwise.
|
|
139
141
|
*/
|
|
140
142
|
function getCompileCacheDir(): string | undefined;
|
|
@@ -205,7 +207,7 @@ declare module "module" {
|
|
|
205
207
|
*/
|
|
206
208
|
data?: Data | undefined;
|
|
207
209
|
/**
|
|
208
|
-
* [Transferable objects](https://nodejs.org/docs/latest-
|
|
210
|
+
* [Transferable objects](https://nodejs.org/docs/latest-v25.x/api/worker_threads.html#portpostmessagevalue-transferlist)
|
|
209
211
|
* to be passed into the `initialize` hook.
|
|
210
212
|
*/
|
|
211
213
|
transferList?: any[] | undefined;
|
|
@@ -214,10 +216,10 @@ declare module "module" {
|
|
|
214
216
|
/**
|
|
215
217
|
* Register a module that exports hooks that customize Node.js module
|
|
216
218
|
* resolution and loading behavior. See
|
|
217
|
-
* [Customization hooks](https://nodejs.org/docs/latest-
|
|
219
|
+
* [Customization hooks](https://nodejs.org/docs/latest-v25.x/api/module.html#customization-hooks).
|
|
218
220
|
*
|
|
219
221
|
* This feature requires `--allow-worker` if used with the
|
|
220
|
-
* [Permission Model](https://nodejs.org/docs/latest-
|
|
222
|
+
* [Permission Model](https://nodejs.org/docs/latest-v25.x/api/permissions.html#permission-model).
|
|
221
223
|
* @since v20.6.0, v18.19.0
|
|
222
224
|
* @param specifier Customization hooks to be registered; this should be
|
|
223
225
|
* the same string that would be passed to `import()`, except that if it is
|
|
@@ -233,12 +235,12 @@ declare module "module" {
|
|
|
233
235
|
function register<Data = any>(specifier: string | URL, options?: RegisterOptions<Data>): void;
|
|
234
236
|
interface RegisterHooksOptions {
|
|
235
237
|
/**
|
|
236
|
-
* See [load hook](https://nodejs.org/docs/latest-
|
|
238
|
+
* See [load hook](https://nodejs.org/docs/latest-v25.x/api/module.html#loadurl-context-nextload).
|
|
237
239
|
* @default undefined
|
|
238
240
|
*/
|
|
239
241
|
load?: LoadHookSync | undefined;
|
|
240
242
|
/**
|
|
241
|
-
* See [resolve hook](https://nodejs.org/docs/latest-
|
|
243
|
+
* See [resolve hook](https://nodejs.org/docs/latest-v25.x/api/module.html#resolvespecifier-context-nextresolve).
|
|
242
244
|
* @default undefined
|
|
243
245
|
*/
|
|
244
246
|
resolve?: ResolveHookSync | undefined;
|
|
@@ -250,7 +252,7 @@ declare module "module" {
|
|
|
250
252
|
deregister(): void;
|
|
251
253
|
}
|
|
252
254
|
/**
|
|
253
|
-
* Register [hooks](https://nodejs.org/docs/latest-
|
|
255
|
+
* Register [hooks](https://nodejs.org/docs/latest-v25.x/api/module.html#customization-hooks)
|
|
254
256
|
* that customize Node.js module resolution and loading behavior.
|
|
255
257
|
* @since v22.15.0
|
|
256
258
|
* @experimental
|
|
@@ -281,9 +283,9 @@ declare module "module" {
|
|
|
281
283
|
* with `vm.runInContext()` or `vm.compileFunction()`.
|
|
282
284
|
* By default, it will throw an error if the code contains TypeScript features
|
|
283
285
|
* that require transformation such as `Enums`,
|
|
284
|
-
* see [type-stripping](https://nodejs.org/docs/latest-
|
|
286
|
+
* see [type-stripping](https://nodejs.org/docs/latest-v25.x/api/typescript.md#type-stripping) for more information.
|
|
285
287
|
* When mode is `'transform'`, it also transforms TypeScript features to JavaScript,
|
|
286
|
-
* see [transform TypeScript features](https://nodejs.org/docs/latest-
|
|
288
|
+
* see [transform TypeScript features](https://nodejs.org/docs/latest-v25.x/api/typescript.md#typescript-features) for more information.
|
|
287
289
|
* When mode is `'strip'`, source maps are not generated, because locations are preserved.
|
|
288
290
|
* If `sourceMap` is provided, when mode is `'strip'`, an error will be thrown.
|
|
289
291
|
*
|
|
@@ -381,59 +383,18 @@ declare module "module" {
|
|
|
381
383
|
| "module-typescript"
|
|
382
384
|
| "wasm";
|
|
383
385
|
type ModuleSource = string | ArrayBuffer | NodeJS.TypedArray;
|
|
384
|
-
/**
|
|
385
|
-
* The `initialize` hook provides a way to define a custom function that runs in
|
|
386
|
-
* the hooks thread when the hooks module is initialized. Initialization happens
|
|
387
|
-
* when the hooks module is registered via {@link register}.
|
|
388
|
-
*
|
|
389
|
-
* This hook can receive data from a {@link register} invocation, including
|
|
390
|
-
* ports and other transferable objects. The return value of `initialize` can be a
|
|
391
|
-
* `Promise`, in which case it will be awaited before the main application thread
|
|
392
|
-
* execution resumes.
|
|
393
|
-
*/
|
|
394
386
|
type InitializeHook<Data = any> = (data: Data) => void | Promise<void>;
|
|
395
387
|
interface ResolveHookContext {
|
|
396
|
-
/**
|
|
397
|
-
* Export conditions of the relevant `package.json`
|
|
398
|
-
*/
|
|
399
388
|
conditions: string[];
|
|
400
|
-
/**
|
|
401
|
-
* An object whose key-value pairs represent the assertions for the module to import
|
|
402
|
-
*/
|
|
403
389
|
importAttributes: ImportAttributes;
|
|
404
|
-
/**
|
|
405
|
-
* The module importing this one, or undefined if this is the Node.js entry point
|
|
406
|
-
*/
|
|
407
390
|
parentURL: string | undefined;
|
|
408
391
|
}
|
|
409
392
|
interface ResolveFnOutput {
|
|
410
|
-
/**
|
|
411
|
-
* A hint to the load hook (it might be ignored); can be an intermediary value.
|
|
412
|
-
*/
|
|
413
393
|
format?: string | null | undefined;
|
|
414
|
-
/**
|
|
415
|
-
* The import attributes to use when caching the module (optional; if excluded the input will be used)
|
|
416
|
-
*/
|
|
417
394
|
importAttributes?: ImportAttributes | undefined;
|
|
418
|
-
/**
|
|
419
|
-
* A signal that this hook intends to terminate the chain of `resolve` hooks.
|
|
420
|
-
* @default false
|
|
421
|
-
*/
|
|
422
395
|
shortCircuit?: boolean | undefined;
|
|
423
|
-
/**
|
|
424
|
-
* The absolute URL to which this input resolves
|
|
425
|
-
*/
|
|
426
396
|
url: string;
|
|
427
397
|
}
|
|
428
|
-
/**
|
|
429
|
-
* The `resolve` hook chain is responsible for telling Node.js where to find and
|
|
430
|
-
* how to cache a given `import` statement or expression, or `require` call. It can
|
|
431
|
-
* optionally return a format (such as `'module'`) as a hint to the `load` hook. If
|
|
432
|
-
* a format is specified, the `load` hook is ultimately responsible for providing
|
|
433
|
-
* the final `format` value (and it is free to ignore the hint provided by
|
|
434
|
-
* `resolve`); if `resolve` provides a `format`, a custom `load` hook is required
|
|
435
|
-
* even if only to pass the value to the Node.js default `load` hook.
|
|
436
|
-
*/
|
|
437
398
|
type ResolveHook = (
|
|
438
399
|
specifier: string,
|
|
439
400
|
context: ResolveHookContext,
|
|
@@ -451,36 +412,15 @@ declare module "module" {
|
|
|
451
412
|
) => ResolveFnOutput,
|
|
452
413
|
) => ResolveFnOutput;
|
|
453
414
|
interface LoadHookContext {
|
|
454
|
-
/**
|
|
455
|
-
* Export conditions of the relevant `package.json`
|
|
456
|
-
*/
|
|
457
415
|
conditions: string[];
|
|
458
|
-
/**
|
|
459
|
-
* The format optionally supplied by the `resolve` hook chain (can be an intermediary value).
|
|
460
|
-
*/
|
|
461
416
|
format: string | null | undefined;
|
|
462
|
-
/**
|
|
463
|
-
* An object whose key-value pairs represent the assertions for the module to import
|
|
464
|
-
*/
|
|
465
417
|
importAttributes: ImportAttributes;
|
|
466
418
|
}
|
|
467
419
|
interface LoadFnOutput {
|
|
468
420
|
format: string | null | undefined;
|
|
469
|
-
/**
|
|
470
|
-
* A signal that this hook intends to terminate the chain of `resolve` hooks.
|
|
471
|
-
* @default false
|
|
472
|
-
*/
|
|
473
421
|
shortCircuit?: boolean | undefined;
|
|
474
|
-
/**
|
|
475
|
-
* The source for Node.js to evaluate
|
|
476
|
-
*/
|
|
477
422
|
source?: ModuleSource | undefined;
|
|
478
423
|
}
|
|
479
|
-
/**
|
|
480
|
-
* The `load` hook provides a way to define a custom method of determining how a
|
|
481
|
-
* URL should be interpreted, retrieved, and parsed. It is also in charge of
|
|
482
|
-
* validating the import attributes.
|
|
483
|
-
*/
|
|
484
424
|
type LoadHook = (
|
|
485
425
|
url: string,
|
|
486
426
|
context: LoadHookContext,
|
|
@@ -634,94 +574,6 @@ declare module "module" {
|
|
|
634
574
|
function wrap(script: string): string;
|
|
635
575
|
}
|
|
636
576
|
global {
|
|
637
|
-
interface ImportMeta {
|
|
638
|
-
/**
|
|
639
|
-
* The directory name of the current module.
|
|
640
|
-
*
|
|
641
|
-
* This is the same as the `path.dirname()` of the `import.meta.filename`.
|
|
642
|
-
*
|
|
643
|
-
* > **Caveat**: only present on `file:` modules.
|
|
644
|
-
* @since v21.2.0, v20.11.0
|
|
645
|
-
*/
|
|
646
|
-
dirname: string;
|
|
647
|
-
/**
|
|
648
|
-
* The full absolute path and filename of the current module, with
|
|
649
|
-
* symlinks resolved.
|
|
650
|
-
*
|
|
651
|
-
* This is the same as the `url.fileURLToPath()` of the `import.meta.url`.
|
|
652
|
-
*
|
|
653
|
-
* > **Caveat** only local modules support this property. Modules not using the
|
|
654
|
-
* > `file:` protocol will not provide it.
|
|
655
|
-
* @since v21.2.0, v20.11.0
|
|
656
|
-
*/
|
|
657
|
-
filename: string;
|
|
658
|
-
/**
|
|
659
|
-
* The absolute `file:` URL of the module.
|
|
660
|
-
*
|
|
661
|
-
* This is defined exactly the same as it is in browsers providing the URL of the
|
|
662
|
-
* current module file.
|
|
663
|
-
*
|
|
664
|
-
* This enables useful patterns such as relative file loading:
|
|
665
|
-
*
|
|
666
|
-
* ```js
|
|
667
|
-
* import { readFileSync } from 'node:fs';
|
|
668
|
-
* const buffer = readFileSync(new URL('./data.proto', import.meta.url));
|
|
669
|
-
* ```
|
|
670
|
-
*/
|
|
671
|
-
url: string;
|
|
672
|
-
/**
|
|
673
|
-
* `import.meta.resolve` is a module-relative resolution function scoped to
|
|
674
|
-
* each module, returning the URL string.
|
|
675
|
-
*
|
|
676
|
-
* ```js
|
|
677
|
-
* const dependencyAsset = import.meta.resolve('component-lib/asset.css');
|
|
678
|
-
* // file:///app/node_modules/component-lib/asset.css
|
|
679
|
-
* import.meta.resolve('./dep.js');
|
|
680
|
-
* // file:///app/dep.js
|
|
681
|
-
* ```
|
|
682
|
-
*
|
|
683
|
-
* All features of the Node.js module resolution are supported. Dependency
|
|
684
|
-
* resolutions are subject to the permitted exports resolutions within the package.
|
|
685
|
-
*
|
|
686
|
-
* **Caveats**:
|
|
687
|
-
*
|
|
688
|
-
* * This can result in synchronous file-system operations, which
|
|
689
|
-
* can impact performance similarly to `require.resolve`.
|
|
690
|
-
* * This feature is not available within custom loaders (it would
|
|
691
|
-
* create a deadlock).
|
|
692
|
-
* @since v13.9.0, v12.16.0
|
|
693
|
-
* @param specifier The module specifier to resolve relative to the
|
|
694
|
-
* current module.
|
|
695
|
-
* @param parent An optional absolute parent module URL to resolve from.
|
|
696
|
-
* **Default:** `import.meta.url`
|
|
697
|
-
* @returns The absolute URL string that the specifier would resolve to.
|
|
698
|
-
*/
|
|
699
|
-
resolve(specifier: string, parent?: string | URL): string;
|
|
700
|
-
/**
|
|
701
|
-
* `true` when the current module is the entry point of the current process; `false` otherwise.
|
|
702
|
-
*
|
|
703
|
-
* Equivalent to `require.main === module` in CommonJS.
|
|
704
|
-
*
|
|
705
|
-
* Analogous to Python's `__name__ == "__main__"`.
|
|
706
|
-
*
|
|
707
|
-
* ```js
|
|
708
|
-
* export function foo() {
|
|
709
|
-
* return 'Hello, world';
|
|
710
|
-
* }
|
|
711
|
-
*
|
|
712
|
-
* function main() {
|
|
713
|
-
* const message = foo();
|
|
714
|
-
* console.log(message);
|
|
715
|
-
* }
|
|
716
|
-
*
|
|
717
|
-
* if (import.meta.main) main();
|
|
718
|
-
* // `foo` can be imported from another module without possible side-effects from `main`
|
|
719
|
-
* ```
|
|
720
|
-
* @since v24.2.0
|
|
721
|
-
* @experimental
|
|
722
|
-
*/
|
|
723
|
-
main: boolean;
|
|
724
|
-
}
|
|
725
577
|
namespace NodeJS {
|
|
726
578
|
interface Module {
|
|
727
579
|
/**
|
|
@@ -795,7 +647,7 @@ declare module "module" {
|
|
|
795
647
|
* Modules are cached in this object when they are required. By deleting a key
|
|
796
648
|
* value from this object, the next `require` will reload the module.
|
|
797
649
|
* This does not apply to
|
|
798
|
-
* [native addons](https://nodejs.org/docs/latest-
|
|
650
|
+
* [native addons](https://nodejs.org/docs/latest-v25.x/api/addons.html),
|
|
799
651
|
* for which reloading will result in an error.
|
|
800
652
|
* @since v0.3.0
|
|
801
653
|
*/
|
|
@@ -829,7 +681,7 @@ declare module "module" {
|
|
|
829
681
|
* Paths to resolve module location from. If present, these
|
|
830
682
|
* paths are used instead of the default resolution paths, with the exception
|
|
831
683
|
* of
|
|
832
|
-
* [GLOBAL\_FOLDERS](https://nodejs.org/docs/latest-
|
|
684
|
+
* [GLOBAL\_FOLDERS](https://nodejs.org/docs/latest-v25.x/api/modules.html#loading-from-the-global-folders)
|
|
833
685
|
* like `$HOME/.node_modules`, which are
|
|
834
686
|
* always included. Each of these paths is used as a starting point for
|
|
835
687
|
* the module resolution algorithm, meaning that the `node_modules` hierarchy
|
|
@@ -899,7 +751,7 @@ declare module "module" {
|
|
|
899
751
|
}
|
|
900
752
|
export = Module;
|
|
901
753
|
}
|
|
902
|
-
declare module "
|
|
903
|
-
import module = require("module");
|
|
754
|
+
declare module "module" {
|
|
755
|
+
import module = require("node:module");
|
|
904
756
|
export = module;
|
|
905
757
|
}
|