node-webcrypto-ossl
node-webcrypto-ossl copied to clipboard
TypeError: (intermediate value).Crypto is not a constructor
const main = async () => {
const crypto = new (await import('node-webcrypto-ossl')).Crypto();
}
main();
TypeError: (intermediate value).Crypto is not a constructor
NB : I cannot use require() since the library using this is a shared library between front and back, and I make a test on window to determine if I use window.crypto (front) or if I dynamically import node-webcrypto-ossl (server). Plus, ES2020 modules do not support require().
Might be related in source code to https://stackoverflow.com/questions/42036349/uncaught-typeerror-intermediate-value-is-not-a-function ?
It's not clear why you've got that exception. I've tried it locally and I don't have such error.
If you are using nodejs version upper then 10 you can use @peculiar/webcrypto module. It based on nodejs crypto API and doesn't require C++ addon.
I'm using [email protected]
"node-webcrypto-ossl": "^2.1.0" node v14.0.0 Windows 10 64 bits

Same error with "@peculiar/webcrypto": "^1.1.1"
