Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

TypeError: (intermediate value).Crypto is not a constructor #162

Open
dtruffaut opened this issue May 10, 2020 · 5 comments
Open

TypeError: (intermediate value).Crypto is not a constructor #162

dtruffaut opened this issue May 10, 2020 · 5 comments

Comments

@dtruffaut
Copy link

dtruffaut commented May 10, 2020

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().

@dtruffaut
Copy link
Author

dtruffaut commented May 10, 2020

@microshine
Copy link
Contributor

It's not clear why you've got that exception. I've tried it locally and I don't have such error.
image
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 node-webcrypto-ossl@2.1.0

@dtruffaut
Copy link
Author

"node-webcrypto-ossl": "^2.1.0"
node v14.0.0
Windows 10 64 bits

ossl

@dtruffaut
Copy link
Author

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

@microshine
Copy link
Contributor

image

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants