After having installed the module socket.io
npm install socket.io --save
I have the following error:
error TS2307: Cannot find module 'socket.io-client'
import
import * as io from 'socket.io-client';
systemjs.config.js
var map = {
'socket.io-client': 'node_modules/socket.io-client/socket.io.js'
}
var packages = {
'socket.io-client': { main: 'socket.io', format: 'cjs', defaultExtension: 'js' }
}
package.json
"dependencies": {
"socket.io": "^1.4.8"
}
typings.d.ts
/// <reference path="../socket.io-client/socket.io.js" />
declare module 'socket.io-client' {
var e: any;
export = e;
}
socket.io-client (Directory)
- socket.io.js
- typings.d.ts
Angular 2 RC5
@nullromo pointed out, the socket.io-client package now has typings built-in. Installing the types separately is no longer necessary
To properly use socket.io in the browser you need to install both the socket.io client package and its typings:
npm i socket.io-client @types/socket.io-client
You are missing typings.
Open typings.d.ts
and add
declare module 'socket.io-client' {
var e: any;
export = e;
}
You can also try to install typings for socket.io via npm i @types/socket.io-client
. I don't know if there are typings available, though.
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