{
  "$type": "site.standard.document",
  "canonicalUrl": "https://johnnyreilly.com/posts/module-ws-does-not-provide-an-export-named-websocketserver",
  "description": "Resolve the ws npm issue: SyntaxError: The requested module ws does not provide an export named WebSocketServer",
  "path": "/posts/module-ws-does-not-provide-an-export-named-websocketserver",
  "publishedAt": "2024-10-15T00:00:00.000Z",
  "site": "at://did:plc:yy3apqjlms24kso7ahn7lbmb/site.standard.publication/3mova7c4nho2b",
  "textContent": "I use Playwright for testing and mock Web Socket calls with the ws package. I recently did an npm upgrade and found myself hitting this error message when I tried to run tests:\n\nIt was caused by the following code:\n\nThe fix was surprisingly simple to implement but hard to search for. That's why I'm writing this.\n\nResolving \"The requested module 'ws' does not provide\"...\n\nThis fix is as simple switching the code to:\n\nAnd that should resolve the issue.",
  "title": "module ws does not provide an export named WebSocketServer"
}