console.log不能与nodejs socket.io项目一起使用?

时间:2022-05-03 16:58:45

This is regarding the following small demo project: https://github.com/lockerfish/nodejs-socket-io-chat/blob/master/chat.js

这是关于以下小型演示项目:https://github.com/lockerfish/nodejs-socket-io-chat/blob/master/chat.js

Has a console.log in it (line 32 of chat.js) that I can never trigger. I also cannot get any other console.log to output anything. The chat server works as expected... but I can't get console log to work at all. Quite simply, nothing gets output to console, period.

其中有一个console.log(chat.js第32行),我永远无法触发。我也无法获得任何其他console.log来输出任何内容。聊天服务器按预期工作...但我无法让控制台日志工作。很简单,没有任何东西输出到控制台,期间。

Why would this be? Does it have something to do with nodejs? Maybe with socket.io? Obviously I'm new to this but not to javascript in general. What am I missing here?

为什么会这样?它与nodejs有关吗?也许用socket.io?显然我是新手,但不是一般的javascript。我在这里想念的是什么?

1 个解决方案

#1


3  

I think it's just that you are looking for the console.log output in the web-browser and not in the terminal. When I tried it it worked fine.

我认为只是你在网络浏览器中而不是在终端中寻找console.log输出。当我尝试它它工作得很好。

All the console.logs in the scripts that node runs is outputted to the window/terminal that starts the script.

节点运行的脚本中的所有console.log都输出到启动脚本的窗口/终端。

#1


3  

I think it's just that you are looking for the console.log output in the web-browser and not in the terminal. When I tried it it worked fine.

我认为只是你在网络浏览器中而不是在终端中寻找console.log输出。当我尝试它它工作得很好。

All the console.logs in the scripts that node runs is outputted to the window/terminal that starts the script.

节点运行的脚本中的所有console.log都输出到启动脚本的窗口/终端。