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?
Use:
import * as io from 'socket.io-client'
I also got the same error, so use:
import * as io from 'socket.io-client'
instead of:
import io from 'socket.io-client';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With