18 Mart 2018 Pazar

sockjs_client_1.SockJS is not a constructor Hatası

            Angular 5 ile socket uygulaması yaparken karşılaştığım hata ve çözümü!




Başla

Spring Boot ve Angular 5 ile belli bir kullanıcıya özel web socket oluşturma uygulaması geliştirmek için takip ettiğim bir uygulamanın client tarafında hata verdiğini ve aşağıdaki adımı uygulayınca düzeldiğini gördüm.

Errors Encountered


1 ) 'ERROR TypeError: sockjs_client_1.default is not a constructor'
2 ) 'ERROR TypeError: Cannot read property 'over' of undefined'
3 ) 'ERROR TypeError: jquery_1.default is not a function'


Adım 1 :

Bağımlılıkları yükle


npm install --save stompjs
npm install --save sockjs-client
npm install --save jquery

Adım 2 :

Aşağıdaki Kodu


import Stomp from 'stompjs';
import SockJS from 'sockjs-client';
import $ from 'jquery';

İle Değiştir (Fixed)


import * as Stomp from 'stompjs';
import * as SockJS from 'sockjs-client';
import * as $ from 'jquery';

Hiç yorum yok:

Yorum Gönder