2

I'm trying to create a WebSocket server with the ws package, but I keep getting this error: Namespace has no exported member 'Server'

I've tried importing the ws package in different ways, but none work. I can't seem to figure out how to make the error disappear. What am I doing wrong here?

import * as http from 'http';
import * as WebSocket from 'ws';

export class Ws {
    private server: http.Server;
    private wss: WebSocket.Server;

    public start(): void {
        this.server = http.createServer();
        this.wss = new WebSocket.Server({ noServer: true });
    }
}
Current
  • 65
  • 1
  • 5

1 Answers1

0

I was able to fix the issue by importing as below.

import { Server } from 'ws';
y15e
  • 159
  • 5