Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'crypto' of undefined #81

Closed
jvandyke-dev opened this issue Jul 25, 2019 · 6 comments
Closed

Cannot read property 'crypto' of undefined #81

jvandyke-dev opened this issue Jul 25, 2019 · 6 comments

Comments

@jvandyke-dev
Copy link

jvandyke-dev commented Jul 25, 2019

Hey guys,

I'm getting a

Cannot read property 'crypto' of undefined

error in my Angular/Node.js project written in TypeScript. I looked in object_hash.js:1 and my guess would be it's coming from the line
r.crypto&&crypto.getRandomValues

I'm totally new to Angular and Node and have no idea how to handle this. I've "npm install"-ed both object-hash and @types/object-hash. I've uninstalled and reinstalled. No luck.

When I open a new folder somewhere else and just try hash( [1, 'hello world'], { algorithm: 'sha512' }) and logging it to the console, it seems to work just fine. There's no problem in my project until it hits the line console.log(hash([string1, string2], { algorithm: 'sha512' })); Any help here?

I should also mention that in a previous non-Angular project, it all worked just fine. I had at the top import hash from 'object-hash';, but now I've had to import * as hash from 'object-hash'; due to a

Module can only be default-imported using the 'allowSyntheticDefaultImports' flag

error. Please help! This might be a super-simple fix, but I have no idea how to fix this.

@v1d3rm3
Copy link

v1d3rm3 commented Aug 2, 2019

Same here.

@antonsimola
Copy link

I have a feeling that this is Angular 8 problem, I started getting this as well after upgrade.

@Amerzel
Copy link

Amerzel commented Sep 30, 2019

Has anyone found a solution to this issue?

@oniice
Copy link

oniice commented Oct 4, 2019

I have a feeling that this is Angular 8 problem, I started getting this as well after upgrade.

Same - updated from Angular 6 to 8 and now have this issue.

Update:

See this here for some explanation. Angular is preventing this from working, as its not a web standard yet

@sandkampderek
Copy link

Version 2.0.1 fixed this for me:
1e0835c
#71

@jonkoops
Copy link
Collaborator

jonkoops commented Feb 2, 2024

Closing this issue, as it seems to have been fixed in 2.0.1.

@jonkoops jonkoops closed this as completed Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants