});\r
} else if (typeof require !== 'undefined') {\r
// Node.js.\r
- crypto = require('crypto');\r
- if (crypto && crypto.randomBytes) {\r
- setPRNG(function(x, n) {\r
- var i, v = crypto.randomBytes(n);\r
- for (i = 0; i < n; i++) x[i] = v[i];\r
- cleanup(v);\r
- });\r
+ try {\r
+ crypto = require('node:crypto');\r
+ if (crypto && crypto.randomBytes) {\r
+ setPRNG(function(x, n) {\r
+ var i, v = crypto.randomBytes(n);\r
+ for (i = 0; i < n; i++) x[i] = v[i];\r
+ cleanup(v);\r
+ });\r
+ }\r
+ } catch (err) {\r
+ throw new Error('failed to load node:crypto')\r
}\r
}\r
})();\r