Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

245
Vistas
NodeJS, crypto.randomUUID is not a function

I'm very new to JS, I want to generate an UUID. Here's what I tried, step by step:

  1. mkdir test
  2. cd test
  3. touch file1.js
  4. Inside file1.js:

let crypto;
try {
  crypto = require('crypto');
} catch (err) {
  console.log('crypto support is disabled!');
}


var uuid = crypto.randomUUID();
console.log(uuid);

And you see the error. What is wrong? I can't find answer anywhere. Node JS version:

node -v shows v12.22.9

enter image description here

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

here you can use randomBytes() method for get unique id

const crypto = require('crypto');
console.log(crypto.randomBytes(20).toString('hex'));

you can also use uuidv4 instead of crypto

const { uuid } = require('uuidv4');
console.log(uuid());
about 4 years ago · Juan Pablo Isaza Denunciar

0

I upgraded NodeJS to newer version, and it worked!

I had some problems, so I tried to remove NodeJS (I had the same problem like this guy: https://github.com/nodesource/distributions/issues/1157).

And installed LTS version: https://askubuntu.com/questions/1265813/how-to-update-node-js-to-the-long-term-support-version-on-ubuntu-20-04.

Now I have:

node -v v16.16.0

and script works! Thank you :)

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda