Search code examples
angularwebsocketwebpackstomp

How to import "stompjs/lib/stomp.min" in angular2-webpack


I have an angular2-webpack app , want to implements stomp,sockjs-client,websocket.

have added "sockjs": "0.3.18", "stompjs": "2.3.3" in package.json.

when write like this in a service :

import * as SockJS from 'sockjs-client';
import { Client, Message, Stomp } from 'stompjs/lib/stomp.min';

there is an err:

can't find name "Client",
can't find name "Message",
can't find name "Stomp",

Solution

  • Why do you expect this code to work? Did you find an example with this syntax somewhere? The Stomp object only contains a lowercase client, and nothing else from your list.

    Just do

    import Stomp from 'stompjs';
    

    And follow the instructions for making a client.