Skip to content

Vite CJS / ESM module import issue (Cannot read properties of undefined (reading 'WebsocketProvider')) #133

@JulianCataldo

Description

@JulianCataldo

Hello there :)

Environments : Astro or Vite, same symptom.

The error:

Cannot read properties of undefined (reading 'WebsocketProvider')

Full live reproduction:

https://codesandbox.io/p/sandbox/inspiring-danny-ryi6q5?file=%2Fsrc%2Fyjs.ts&selection=%5B%7B%22endColumn%22%3A33%2C%22endLineNumber%22%3A11%2C%22startColumn%22%3A33%2C%22startLineNumber%22%3A11%7D%5D

The fix:

// import { WebsocketProvider } from "y-websocket";
// HACK: Import from source directly
import { WebsocketProvider } from "/node_modules/y-websocket/src/y-websocket.js";

Cheers

Huly®: YJS-575

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions