Coderrob brand logo Coderrob

Hi, I'm Rob—programmer, Pluralsight author, software architect, emerging technologist, and lifelong learner.


Rollup, UUID, and Error Crypto getRandomValues() Not Supported - Solved


Sat, 24 Aug 2024

I ran into this error while using Rollup and the uuid package:

Error: Crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported

The problem? It boiled down to this small mistake in my Rollup config:

// rollup.config.js
plugins: [
  nodeResolve({
    extensions: ['.ts', '.js'],
    exportConditions: 'node', // Wrong: should be an array
  }),
  // Other plugins...
],

The solution was simple. exportConditions needs an array, not a string:

// rollup.config.js
plugins: [
  nodeResolve({
    extensions: ['.ts', '.js'],
    exportConditions: ['node'], // Fixed: now it's an array
  }),
  // Other plugins...
],

TypeScript would’ve caught this, but in plain JS, it slipped through. Lesson (re)learned. Always verify.