javascript events.js:72 抛出 er; // 未处理的“错误”事件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24525253/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 02:58:47  来源:igfitidea点击:

events.js:72 throw er; // Unhandled 'error' event

javascript

提问by zooksanish

I am trying to do on authetication and authorization ,from some of the post i found out to install npm , I'av install npm too still am unable to solve the error:

我正在尝试进行身份验证和授权,从我发现安装 npm 的一些帖子中,我也安装 npm 仍然无法解决错误:

mar@ubuntu:~/2014/june/12/api$ node blog.js

mar@ubuntu:~/2014/june/12/api$ node blog.js

Blog API is starting on port 6379

博客 API 在端口 6379 上启动

events.js:72

事件.js:72

    throw er; // Unhandled 'error' event
          ^

Error: listen EADDRINUSE

错误:听 EADDRINUSE

         at errnoException (net.js:904:11)

         at Server._listen2 (net.js:1042:14)

         at listen (net.js:1064:10)

         at Server.listen (net.js:1138:5)

 at Function.app.listen 

(/home/mar/2014/june/12/api/node_modules/express/lib/application.js:531:24)

(/home/mar/2014/june/12/api/node_modules/express/lib/application.js:531:24)

        at Object.<anonymous> (/home/mar/2014/june/12/api/blog.js:9:5)

        at Module._compile (module.js:456:26)

        at Object.Module._extensions..js (module.js:474:10)

        at Module.load (module.js:356:32)

        at Function.Module._load (module.js:312:12)

回答by Kevin Sandow

There is an error code in your dump:

您的转储中有错误代码:

EADDRRINUSE which is short for "error address in use" which usually occurs when the port your node.js server ist trying to start is already in use.

EADDRRINUSE 是“使用中的错误地址”的缩写,通常在您的 node.js 服务器尝试启动的端口已被使用时发生。

Check what port is supposed to be used and figure out what else is already running at that port. It might even be your blog.js you started earlier.

检查应该使用的端口并找出该端口上已经运行的其他端口。它甚至可能是您之前开始的 blog.js。



Edit:

编辑:

Port 6379 is the default port for the redis, which you probably have already ... you should use a different port. If your trying it locally just to start developing and figure out how things works, keep the 3001 and start up a browser at http://localhost:3001/

端口 6379 是 redis 的默认端口,您可能已经使用了……您应该使用不同的端口。如果您在本地尝试它只是为了开始开发并弄清楚事情是如何工作的,请保留 3001 并在以下位置启动浏览器http://localhost:3001/

The Allow-Origin Header should contain the correct hostname under which your server is reachable, as long as your running it locally http://localhostshould be fine, a port might be necessary.

Allow-Origin 标头应包含可访问服务器的正确主机名,只要您在本地运行它http://localhost应该没问题,可能需要一个端口。