node.js 节点 events.js:167 throw er; // 未处理的“错误”事件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/50782463/
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-09-02 18:49:41  来源:igfitidea点击:

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

jsonnode.jsreactjs

提问by frente_fin

I'm trying to use JSON Server in a React App. However, I keep getting the following error.

我正在尝试在 React 应用程序中使用 JSON 服务器。但是,我不断收到以下错误。

events.js:167
  throw er; // Unhandled 'error' event
  ^
Emitted 'error' event at:
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1498:12)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:50:17)

I've upgraded npm and node to the latest versions. I've killed all processes with killall node and sudo killall -9 node

我已将 npm 和 node 升级到最新版本。我已经用 killall node 和 sudo killall -9 node 杀死了所有进程

Any ideas what may be causing the issue?

任何想法可能导致问题?

回答by Salma

I had the same issue I ran killall nodethen npm startafter that my local server at port 5000 worked again. Hope that helps you.

我有我跑了同样的问题,killall node然后npm start我在端口5000的本地服务器后再次合作。希望能帮到你。

回答by Mahdi Irani

Removing the node_modulesdirectory and reinstalling again using npm installshould solve the problem.

删除node_modules目录并重新安装使用npm install应该可以解决问题。

回答by Peter Sobhi

Try npm startas superuser: sudo npm start

npm start以超级用户身份尝试:sudo npm start

This worked for me.

这对我有用。

回答by Moshtaba Darzi

test another adb device... real smartphone or android studie or genymotion npm startin your project open new tab and run react-native run-androidand press ctrl + cin past terminal tab

测试另一个adb 设备...真正的智能手机或 android 研究或 genymotion npm start在您的项目中打开新选项卡并运行react-native run-android并在过去的终端选项卡中按ctrl + c

i guess why this problem is we cant run http://localhost:8081/debugger-ui/

我想为什么这个问题是我们不能运行http://localhost:8081/debugger-ui/

回答by Levine Veblen

restart the WebStormwas worked for me. instead of removed 'node_modules' folderand reinstall modulesby npm install.

重新启动WebStorm对我有用。代替去除“node_modules”文件夹中,并重新安装模块通过npm install

回答by Karthi The Programmer

For windows users, run command

对于 Windows 用户,运行命令

Taskkill /IM node.exe /F

It works for me.

这个对我有用。

Reference:

参考:

https://stackoverflow.com/a/51408717/9033834

https://stackoverflow.com/a/51408717/9033834

回答by Eldlabs

I ran npm installand then npm updateand it works again.

我运行npm install然后npm update,它再次运行。

回答by Manish

I have the same issue. Basically, I am using node v10+ but my project was created in v8.11.4. All the modules were used according to the older version(v8), that's why I am facing the issue. So there are two solutions either update your module or downgrade the node.

我有同样的问题。基本上,我使用的是 node v10+,但我的项目是在 v8.11.4 中创建的。所有模块都是根据旧版本(v8)使用的,这就是我面临这个问题的原因。所以有两种解决方案,要么更新你的模块,要么降级节点。

I have solved by downgrading the node from v10 to v8. Because some of the modules are not possible to update due to project dependency.

我已经通过将节点从 v10 降级到 v8 来解决。因为部分模块由于项目依赖无法更新。

回答by ChumiestBucket

Little late, but for any out there struggling, I came across this error by creating the React app without using sudo. Using sudowhile running npx create-react-app app-namefixed the issue.

有点晚了,但对于任何在那里挣扎的人,我通过创建 React 应用程序而不使用sudo. 使用sudo在运行npx create-react-app app-name固定的问题。

回答by Vandelay Web

If you are running on Windows and have IIS running on your machine, ensure the IIS server is stopped if you are trying to run on port 8080. You can also change the port to not bring IIS into it.

如果您在 Windows 上运行并且在您的计算机上运行 IIS,如果您尝试在端口 8080 上运行,请确保 IIS 服务器已停止。您还可以更改端口以不将 IIS 带入其中。

npm start -- --port 8000