Reputation: 1905
I've got socket.io-client
installed in an Angular 5.2 application, and after following the steps to connect (which worked before for me, many times) I'm getting a weird error.
TypeError: socket_io_client_1.default is not a function
at new AuthService (auth.service.ts:15)
at _createClass (core.js:10891)
at _createProviderInstance$1 (core.js:10865)
at resolveNgModuleDep (core.js:10850)
at NgModuleRef_.get (core.js:12087)
at resolveDep (core.js:12577)
at createClass (core.js:12439)
at createDirectiveInstance (core.js:12284)
at createViewNodes (core.js:13742)
at callViewAction (core.js:14176)
Here's to 15th line in AuthService
import {Injectable} from '@angular/core';
import io from 'socket.io-client';
import {CookieService} from 'ngx-cookie-service';
@Injectable()
export class AuthService {
socket;
domain = 'http://localhost:3000';
isUserLoggedIn = false;
cookie_key = '';
user = {};
constructor(private cookieService: CookieService) {
this.socket = io(this.domain);
}
No idea what's going on at this point. Any pointers?
Upvotes: 9
Views: 7716
Reputation: 31
I also got the same error, so use:
import * as io from 'socket.io-client'
instead of:
import io from 'socket.io-client';
Upvotes: 3