node:timers
Node.jstimers module, resolvable via both ESM import and CommonJS require.
It re-exports the runtime's timer globals as named bindings.
| Export | Description |
|---|---|
setTimeout / clearTimeout | Schedule / cancel a one-shot callback. |
setInterval / clearInterval | Schedule / cancel a repeating callback. |
setImmediate / clearImmediate | Schedule / cancel a callback for the next loop iteration. |
active() / unenroll() helpers
are intentionally omitted.
node:timers/promises
Thenode:timers/promises submodule provides Promise-based timers.
| Export | Description |
|---|---|
setTimeout(delay?, value?, options?) | Resolves with value after delay ms; honours options.signal (AbortSignal). |
setImmediate(value?, options?) | Resolves with value on the next loop iteration; honours options.signal. |
setInterval(delay?, value?, options?) | Returns an async iterator that yields once per interval. |
scheduler | scheduler.wait(delay, options?) and scheduler.yield(). |
javascript
import { setTimeout as sleep } from "node:timers/promises";
await sleep(100);See also
- Node.js upstream: