I am trying to add the ws
npm library to my Angular Project but can't figure out how to do it correctly.
I have installed it using npm install ws
. Now I am trying to import it in the app.module.ts
file.
I've tried import { WebSocket } from 'ws';
and in imports
I've added WebSocket
.
I've also tried other form of writing it and they all give me an error: 'WebSocket' can only be imported by turning on the 'esModuleInterop' flag and using a default import.
Removing the line import { WebSocket } from 'ws';
and leaving WebSocket
in the imports list seems to be okay. But I think that this is the wrong WebSocket because I don't see anything related to the ws
library.
Is this alright or am I doing something wrong?
I was taking a look at Sending and receiving text data
in this tutorial https://www.npmjs.com/package/ws#sending-and-receiving-text-data for them it seems to work.