调用节点app.js时出错,[node js socket io]如何修复它?

时间:2018-04-29 13:40:59

标签: node.js linux websocket socket.io centos7

调用节点app.js时出错,[node js socket io]如何修复它?

  1. cd /home/admin/web/my-doamin-name/public_html
  2. npm init
  3. npm install --save express socket.io
  4. node app.js
  5. ............................................... ................

    但仍显示此错误

    /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时,它无效,我该怎么办?

1 个答案:

答案 0 :(得分:0)

我不认为您在使用快递时需要使用http模块。

mousedown