This will cause an error on following line when the global.Websocket would be true.
const WS = global.WebSocket || require('ws');
global.WebSocket: This will points to Node.js's native WebSocket, which does not include a Server class.
require('ws'): The ws package includes both WebSocket and WebSocket.Server, but this fallback is skipped because global.WebSocket is already defined in Node.js v22
Prep PR for node 22
In node v22, websocket is enabled by default https://github.com/nodejs/node/pull/51594
This will cause an error on following line when the global.Websocket would be true. const WS = global.WebSocket || require('ws');
global.WebSocket: This will points to Node.js's native WebSocket, which does not include a Server class. require('ws'): The ws package includes both WebSocket and WebSocket.Server, but this fallback is skipped because global.WebSocket is already defined in Node.js v22