node.js express socket.io port 3000正在使用中 [英] node.js express socket.io port 3000 in use

查看:171
本文介绍了node.js express socket.io port 3000正在使用中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在追踪( http://socket.io/get-started/chat/ )关于如何使用socket.io制作一个简单的聊天应用程序的教程。

I've been following this(http://socket.io/get-started/chat/) tutorial on how to make a simple chat application using socket.io.

我尝试使用Express创建它,我想知道为什么端口3000已经在使用?以下代码将无法正常工作,除非更改端口号。

I tried to however use Express to create it and I was wondering why port 3000 is already in use? The code below will not work unless I change the port number.

/* Make the http server listen on port 3000. */
http.listen(3000, function(){
 console.log('listening on *:3000');
});

表示使用端口做其他事情,如路由或某事?
有没有一个简单的方法来找到那个端口发生了什么?

Does express use the port to do other things like routing or something? Is there a simple way to find what is happening on that port?

我也可能在做我想要的东西诡计:

I may also be doing something dodgy with my require things:

var express = require('express');
var app = require('express')();
var http = require('http').Server(app);
var router = express.Router();
var io = require('socket.io')(http);

谢谢。

推荐答案

我遇到这个问题,我解决了这个:

I ran into this problem too and I solved it by this:

不要使用 npm开始启动您的网络应用程序

Do not use npm start to start your web app

使用节点app.js 而不是

这篇关于node.js express socket.io port 3000正在使用中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆