cmdruid / tapscript

A humble library for working with Tapscript and Bitcoin Transactions.
https://www.npmjs.com/package/@cmdcode/tapscript
Creative Commons Zero v1.0 Universal
196 stars 50 forks source link

crypto.getRandomValues must be defined node js error #2

Closed mgpai22 closed 1 year ago

mgpai22 commented 1 year ago

Hello I get the following error in node js:

/@cmdcode/tapscript/dist/module.js:104
    throw new Error('crypto.getRandomValues must be defined');

As a local work around I changed (line 56 in module.js)

const crypto$2 = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;

to

import * as crypto$2  from 'crypto';
cmdruid commented 1 year ago

What version of nodejs are you running? I believe you need version 19 or above for the new globalThis object to work.

mgpai22 commented 1 year ago

Yes I was running an older version, node 19+ works great!