Import socket.io with system.js

I am trying to include Aurelia frameworks in a project sockets.io

. I have sockets installed:

jspm install npm:socket.io

      

then I would like to import:

import {io} from "socket.io";

      

And the results:

GET http://localhost:9000/jspm_packages/npm/socket.io-client@1.3.5/package.js 404 (Not Found)

      

Where is the problem? Why is there a link to package.js

and not to package.json

or socket.io.js

?

+3


source to share


3 answers


On the client side (Aurelia) you have to use the server.io client



import io from 'socket.io-client';

var socket = io('http://localhost:9000');
socket.emit('news', { hello: 'world' });

      

+10


source


If your server is running socket-io it will still serve the client. This way you can add to the map section of your file config.js

:



"socket.io" : "/socket.io/socket.io.js"

      

+1


source


I recently had problems downloading "socket.io-client" and found that

import io from 'socket.io-client';
var socket = io();

      

won't work as it tries to load socket_io_client.default

which is undefined. Instead, I had to use

import io = require('socket.io-client');
var socket = io();

      

-1


source







All Articles