My nodeJs script (/usr/bin/nodeapps/my/index.js):
app = require('express.io')();
app.http().io();
console.log("Ready!");
app.io.sockets.on('connection', function(s) {
console.log("Utente connesso!");
s.on('disconnect', function() {
console.log('Utente disconnesso!');
});
});
app.io.route('msg', function(req) {
console.log(req.data.messaggio);
app.io.sockets.emit('res', {
data: req.data.messaggio
});
});
app.get('/', function(req, res) {
res.sendfile('index.html')
});
app.get('/s', function(req, res) {
res.sendfile('s.html')
});
app.listen(9000);
Dependencies (/usr/bin/nodeapps/my/package.json):
{
"name": "socket-chat-example",
"version": "0.0.1",
"description": "my first socket.io app",
"dependencies": {
"coffee-script": "*",
"express.io": "*",
"connect": "*"
}
}
node version (node --version):
v5.0.0
The problem:
when I run:
node index.js
or:
node index
The bash runs, but the express.io server doesn't start. Only console.log("Ready!");
Ready!
and after 1 second the script stops and terminal show me a new line without any errors.
in Windows all works fine, the server starts and wait for connections.