TypeError: ws.Server is not a constructor
JavaScript2022. 11. 1. 15:28TypeError: ws.Server is not a constructor

웹소켓 서버를 생성 및 구동하려다 해당 오류를 만난다면 살짝만 수정해주면 된다. ws 버전에 관한 문제 // 기존코드 import ws from "ws"; const wws = new ws.Server({ server: HTTPServer, }); 위 코드에서 // 수정코드 import ws, { WebSocketServer } from "ws"; const wws = new WebSocketServer({ server: HTTPServer, }); 위와 같이 변경하면 된다.

image