svelte-websocket-store
svelte-websocket-store copied to clipboard
ReferenceError: WebSocket is not defined
file:///{{url}}/node_modules/svelte-websocket-store/src/index.mjs:54 socket = new WebSocket(url, socketOptions); ^
ReferenceError: WebSocket is not defined at open (file:///{{url}}/node_modules/svelte-websocket-store/src/index.mjs:54:5) at Object.subscribe (file:///{{url}}/node_modules/svelte-websocket-store/src/index.mjs:84:7) at Proxy.subscribe (/{{url}}/node_modules/svelte/internal/index.js:59:25) at eval (/src/routes/dashboard.svelte:36:48) at Object.$$render (/{{url}}/node_modules/svelte/internal/index.js:1758:22) at Object.default (/.svelte-kit/generated/root.svelte:58:129) at eval (/src/routes/__layout.svelte:85:75) at Object.$$render (/{{url}}/node_modules/svelte/internal/index.js:1758:22) at eval (/.svelte-kit/generated/root.svelte:50:126) at $$render (/{{url}}/node_modules/svelte/internal/index.js:1758:22)
Node.js v18.2.0
Using Svelte-kit
I don't see any lines in the source that make it work for the node js environment. The index.mjs directly refers to WebSocket which would only work if you're inside the browser. So this doesn't work for Svelte Kit (at least as of today).
FYI, to use with SvelteKit you can employ conditionals with browser from $app/env to ensure this library is only attempted to run on the client-side.