apteryxxyz / next-ws

Add support for WebSockets in Next.js app directory.
https://npmjs.com/next-ws
171 stars 12 forks source link

Dev error #5

Closed tonxxd closed 1 year ago

tonxxd commented 1 year ago

Hi, i am getting this error after running the patch and running next dev

TypeError: ws_1.WebSocketServer is not a constructor
    at getWsServer (/node_modules/next-ws/server/utilities/ws.js:11:12)
    at Object.setupWebSocketServer (/node_modules/next-ws/server/setup.js:10:43)
    at new NextNodeServer (/node_modules/next/dist/server/next-server.js:283:31)
    at new DevServer (/node_modules/next/dist/server/dev/next-dev-server.js:149:9)
    at NextServer.createServer (/node_modules/next/dist/server/next.js:179:24)
    at /node_modules/next/dist/server/next.js:200:42
    at async NextServer.prepare (/node_modules/next/dist/server/next.js:161:24)
    at async Server.<anonymous> (/node_modules/next/dist/server/lib/render-server.js:136:17) {
  type: 'TypeError'
}

Any idea why it might happen?

patch output

Supported versions: >=13.1.1 <=13.4.8 || >=13.4.9 <=13.4.12. 13.4.12, 13.1.1, 13.4.8
[next-ws] Patching Next.js v13.4.12 with patch ">=13.4.9 <=13.4.12"...
[next-ws] Adding WebSocket server setup script to NextNodeServer constructor...
[next-ws] Adding 'SOCKET' to the page module interface type...
[next-ws] Saving patch information file...
[next-ws] All done! You can now install the core Next WS package if you haven't already

next version 13.4.12

EDIT forgot to install ws

apteryxxyz commented 1 year ago

Yeah I recently made ws a peer dependency, I should probably add information about that to the README. Also noticed I left a console.log in the cli package, oops.