node.js错误消息events.js:183 throw er;//未处理的“错误"事件 [英] node.js error message events.js:183 throw er; // Unhandled 'error' event
问题描述
围绕Microsoft的botframework,当我尝试运行bot的主要文件app.js文件时,在关闭bot模拟器和所有程序并运行该应用程序后,第一次很好. js,此错误消息会弹出
Playing around Microsoft's botframework, when I try to run the app.js file, which is the main file of the bot, the first time is fine, after I close the bot emulator, and all programs, and run the app.js again, this error message pops out
events.js:183
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE :::3978
at Object._errnoException (util.js:1022:11)
at _exceptionWithHostPort (util.js:1044:20)
at Server.setupListenHandle [as _listen2] (net.js:1351:14)
at listenInCluster (net.js:1392:12)
at Server.listen (net.js:1476:7)
at Server.listen (C:\Users\yu\Documents\GitHub\BotBuilder-
Samples\Node\cards-AdaptiveCards\node_modules\restify\lib\server.js:404:32)
at Object.<anonymous> (C:\Users\yu\Documents\GitHub\BotBuilder-
Samples\Node\cards-AdaptiveCards\app.js:10:8)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
我找到了解决方案,好像第二次运行js文件时使用了端口3978,我必须使用cmd查找正在使用该端口的任务,然后终止该任务.
I found some solution to this, It looks like the port 3978 was taken when I run the js file for the second time, and I have to use cmd to find which task is using that port, and then kill the task.
C:\>netstat -aon|findstr 3978
尽管我已经关闭了所有程序,所以这个已经占用了端口
so this one is taking the port, although I already closed all programs
TCP 0.0.0.0:3978 0.0.0.0:0 LISTENING 13140
TCP [::]:3978 [::]:0 LISTENING 13140
实际上它是node.exe本身,它仍在后台运行
actually it is node.exe itself, it still running at background
C:\Users\yu>tasklist|findstr 13140
node.exe 13140 Console 1 42,064 K
我需要杀死它
C:\Users\yu>taskkill /f /t /im node.exe
当我想多次运行文件时,是否有一种方法可以不总是重复执行此操作,今天它才开始连接,对于所有不同的app.js文件,它都包含正式的示例代码.在过去的一个月中,一切都很好,我使用的IDE是sublime text 3,node.js版本是8.9.4 lts
Is there a way to not always repeat doing this when I want to run the file more than one time, it just starts to go wired today, and I mean for all different app.js files, include offical sample code. For the past one month, everything was fine, the IDE I am using is sublime text 3, node.js version is 8.9.4 lts
推荐答案
这是一个非常普遍的问题,可以通过以下两种方法之一轻松解决.
-
尝试关闭正在使用您的端口的进程.
Try to close the process that is using your port.
netstat -tulnp | grep <port_number>
netstat -tulnp | grep <port_number>
安装以下pakcage可以永久修复它.
Installing the below pakcage fixed it for me forever.
npm install ws@3.3.2 --save-dev --save-exact
npm install ws@3.3.2 --save-dev --save-exact
在终端中运行以下命令:
Run this command in your terminal :
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
对于Arch Linux,将此行添加到/etc/sysctl.d/99-sysctl.conf:
fs.inotify.max_user_watches=524288
然后执行:
sysctl --system
这也将在重新启动后持续存在.
This will also persist across reboots.
https://github.com/guard/listen/wiki/Increating-the-amount-of-inotify-watchers#the-technical-details
任何一种解决方案都可以使用.如果没有,请重新启动系统,然后再次检查.
Either one of the solutions will work . If not then restart your system and check again.
这篇关于node.js错误消息events.js:183 throw er;//未处理的“错误"事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!