【发布时间】:2018-04-29 13:40:58
【问题描述】:
调用node app.js时出错,[node js socket io]如何解决?
cd /home/admin/web/my-doamin-name/public_htmlnpm initnpm install --save express socket.ionode app.js
.................................................. ......
但还是显示这个错误
/home/admin/web/my-domain-name/public_html/app.js:9
consloe.log('start server on port :3000');
^
ReferenceError: consloe is not defined
at Server.<anonymous> (/home/admin/web/my-domain-name/public_html/app.js:9:2)
at Server.g (events.js:260:16)
at emitNone (events.js:67:13)
at Server.emit (events.js:166:7)
at emitListeningNT (net.js:1257:10)
at nextTickCallbackWith1Arg (node.js:431:9)
at process._tickCallback (node.js:353:17)
at Function.Module.runMain (module.js:443:11)
at startup (node.js:139:18)
at node.js:968:3
.................................................. …………
app.js
var app = require('express')();
var http = require('https').Server(app);
app.get('/', function(req, res){
res.sendfile('index.html');
});
http.listen(3000, function(){
consloe.log('start server on port :3000');
});
.................................................. ........
index.html
<html>
<head></head>
<body>HELLO WORLD</body>
</html>
当我尝试访问mydomain.com:3000 时,它不起作用,我该怎么办?
【问题讨论】:
-
consloe.log=>console.log
标签: node.js linux websocket socket.io centos7