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

Issue with crypto in random.js #2

callum-atwal opened this issue Jan 13, 2020 · 1 comment

Issue with crypto in random.js #2

callum-atwal opened this issue Jan 13, 2020 · 1 comment


Copy link

@callum-atwal callum-atwal commented Jan 13, 2020


I thought I'd just raise an issue for this as I was unsure of a good workaround.

I ran into an issue when using Yjs with Angular. Namely, since it is still run under a node environment, the lib0 library attempts to use node's crypto instead of browser crypto. (see this line


Line 11 in 17d4bee

const nodeCrypto = env.isNode ? require('crypto') : null

However, Angular did not like this since it doesn't want to expose core node modules in this way to the frontend (understandable) - it would give an error saying it could not resolve requiring crypto.

My workaround, in this case, was just to remove this line altogether and modify the rest of the file such that it only uses browser crypto.

I just thought I'd make you, and anyone else that got as far as figuring this out, aware of the issue.
Maybe perhaps there is a better way of determining the environment?


This comment has been minimized.

Copy link

@dmonad dmonad commented Jan 15, 2020

Hi @callum-atwal, thanks for reporting this. I fixed this in lib0#0.2.x . If you are using Yjs, try updating to v13.0.0-105.

@dmonad dmonad closed this Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.