gpt4 book ai didi

react-native - 为什么npm start给我有关端口的错误?

转载 作者:行者123 更新时间:2023-12-04 16:22:58 24 4
gpt4 key购买 nike

我不知道为什么在输入“npm start”后它给我错误。我正在尝试使用相同的WIFI打开我的React Native项目。我认为这与港口有关。

这是错误:

Loading dependency graph...events.js:183
throw er; // Unhandled 'error' event
^

Error: listen EADDRINUSE :::8081
at Server.setupListenHandle [as _listen2] (net.js:1360:14)
at listenInCluster (net.js:1401:12)
at Server.listen (net.js:1485:7)
at D:\rnprojects\testproject\node_modules\metro\src\index.js:156:18
at new Promise (<anonymous>)
at Object.<anonymous>
(D:\rnprojects\testproject\node_modules\metro\src\index.js:155:12)
at Generator.next (<anonymous>)
at step (D:\rnprojects\testproject\node_modules\metro\src\index.js:47:262)
at D:\rnprojects\testproject\node_modules\metro\src\index.js:47:422
at <anonymous>
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! testproject@0.0.1 start: `node node_modules/react-native/local-
cli/cli.js start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the testproject@0.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional
logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\ASUS\AppData\Roaming\npm-cache\_logs\2018-09-
29T06_20_58_251Z-debug.log

npm start之后:
enter image description here

最佳答案

可能端口已在使用中。当我第一次运行react-native run-android然后npm start时,我遇到类似的问题。我这样解决:
首先,获取在端口8081中运行的进程的ID:

sudo lsof -i :8081

然后杀死它:
kill -9 ID_SHOWN_FROM_PREVIOUS_CMD 

ID_SHOWN_FROM_PREVIOUS_CMD将类似于25534
因此,在此之后,首先运行npm start,然后再运行native-android

关于react-native - 为什么npm start给我有关端口的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52565750/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com