Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

import socket.io using system.js

I am trying to include to Aurelia framework project sockets.io. I have installed sockets by:

jspm install npm:socket.io

then, I would like to import:

import {io} from "socket.io";

And the results is:

GET http://localhost:9000/jspm_packages/npm/[email protected]/package.js 404 (Not Found)

Where is the problem? Why is there a reference to package.js and not to package.json or socket.io.js ?

like image 861
InnerWorld Avatar asked Mar 04 '26 06:03

InnerWorld


2 Answers

On the client side (Aurelia), you should use the server.io client

import io from 'socket.io-client';

var socket = io('http://localhost:9000');
socket.emit('news', { hello: 'world' });
like image 71
Nicolas Pennec Avatar answered Mar 06 '26 21:03

Nicolas Pennec


If your server is running socket-io then it will be serving up the client anyway. Thus, you should be able to add to the map section of your config.js file:

"socket.io" : "/socket.io/socket.io.js"
like image 40
Meirion Hughes Avatar answered Mar 06 '26 19:03

Meirion Hughes