Error: Cannot find module 'yjs'

Hey folks,

I’m getting this weird “Error: Cannot find module ‘yjs’” error when creating a WebrtcProvider or a WebsocketProvider. I’ve already installed yjs and have tried upgrading and downgradind versions of both yjs and the providers. Nothing seemed to work. I’m creating the provider in a useEffect (for testing) inside of a NextJS 14 component (client side component). Any ideas what could be going wrong or what I can do?

Cheers,
Gumbee

That’s strange. It suggests that the yjs module is not installed. Are you able to import yjs directly and create a Y.Doc without WebrtcProvider or WebsocketProvider?

You might also run npm ls yjs to confirm that you have one and only one yjs library installed. It should dedupe yjs brought in by your providers if they all use the same version.

Found the issue. Turns out it was because I was developing a library which import yjs locally using yarn link. When published and then imported, or when using yalc to develop locally it worked just fine.

Appreciate the help :pray: