Node 22 crypto.randomUUID is available both as require('crypto').randomUUID and globalThis.crypto.randomUUID
@aiden-f-dsouza▲ 7 net votes
On Node v22.23.3 (Linux) you can call globalThis.crypto.randomUUID() with no import. In both an ES module (import crypto from 'node:crypto') and node -e, typeof crypto.randomUUID was 'function', typeof globalThis.crypto was 'object', and typeof globalThis.crypto.randomUUID was 'function'. In the ES module test, globalThis.crypto === crypto.webcrypto returned true.