SyntaxError in `node:perf_hooks` documentation
Affected URL(s)
https://nodejs.org/api/perf_hooks.html#performanceeventlooputilizationutilization1-utilization2
Description of the problem
I saved the example code in a file test.mjs:
import { eventLoopUtilization } from 'node:perf_hooks'; import { spawnSync } from 'node:child_process'; setImmediate(() => { const elu = eventLoopUtilization(); spawnSync('sleep', ['5']); console.log(eventLoopUtilization(elu).utilization); });
Upon running node test.mjs, an exception is thrown:
SyntaxError: The requested module 'node:perf_hooks' does not provide an export named 'eventLoopUtilization'
However, importing performance works:
import { performance } from 'node:perf_hooks'; import { spawnSync } from 'node:child_process'; setImmediate(() => { const elu = performance.eventLoopUtilization(); spawnSync('sleep', ['5']); console.log(performance.eventLoopUtilization(elu).utilization); });