Use generic node package in Angular2

I am trying to use a generic node module ( websocket ) that was not built for TS in my Angular2 app.I also installed @ types / websocket and imported it into my service like this:

import * as WebSocket from 'websocket';

      

or

import { client } from 'websocket';

      

and point out that there are no errors in VScode or on ngBuild, but in my browser console I got this error:

TypeError: __WEBPACK_IMPORTED_MODULE_1_websocket__.client is not a constructor

      

but it's actually a constructor! I use it in expressjs and regular node and everything is fine.

+3


source to share





All Articles