启动RN服务端口被占用

npx react-native start --port 8081 --host 127.0.0.1启动RN的Metro服务,报错:

bash 复制代码
D:\projects\odn\RN\LightODN>npx react-native start --port 8081 --host 127.0.0.1
warn Package react-native-sqlite-storage contains invalid configuration: "dependency.platforms.ios.project" is not allowed. Please verify it's properly linked using "react-native config" command and contact the package maintainers about this.
warn Package react-native-amap3d contains invalid configuration: "dependency.platforms.ios.project" is not allowed. Please verify it's properly linked using "react-native config" command and contact the package maintainers about this.
error listen EADDRINUSE: address already in use 127.0.0.1:8081.
Error: listen EADDRINUSE: address already in use 127.0.0.1:8081
    at Server.setupListenHandle [as _listen2] (net.js:1331:16)
    at listenInCluster (net.js:1379:12)
    at doListen (net.js:1516:7)
    at processTicksAndRejections (internal/process/task_queues.js:83:21)
info Run CLI with --verbose flag for more details.

8081端口被占,查找进程id

bash 复制代码
D:\projects\odn\RN\LightODN>netstat -aon | findstr :8081
  TCP    127.0.0.1:8081         0.0.0.0:0              LISTENING       18312
  TCP    127.0.0.1:8081         127.0.0.1:60981        ESTABLISHED     18312
  TCP    127.0.0.1:8081         127.0.0.1:60982        ESTABLISHED     18312
  TCP    127.0.0.1:60981        127.0.0.1:8081         ESTABLISHED     5348
  TCP    127.0.0.1:60982        127.0.0.1:8081         ESTABLISHED     5348

执行 taskkill /PID 18312 /F

bash 复制代码
taskkill /PID 18312 /F

然后再执行启动RN的Metro服务命令就可以了,ok.

相关推荐
mmsx2 小时前
耳切法切带洞多边形:论文能跑通,真实数据为什么崩
android·kotlin
洞见前行2 小时前
你的 Activity 关了,为什么还活着?Android 内存泄漏从发现、定位到线上治理
android·性能优化·leakcanary
Kapaseker4 小时前
Kotlin 又要加语法糖了:这次轮到 if-else
android·kotlin
恋猫de小郭6 小时前
Flutter 3.50 & Dart 3.14 发布,快来看看有什么更新吧
android·前端·flutter
Starry-sky(jing)1 天前
Vidda ADB 开启:R Pro 65 找不到开发者选项的处理与连接验收
android·adb·远程控制·电视·vidda
雨白1 天前
从原理到实践:使用 Kotlin KSP 仿写 ButterKnifeLite
android·kotlin
疯华整猫1 天前
把二十七个 init 从首帧前面搬走:用 Trae 把启动优化钉进 CI
android·性能优化·ai编程
传奇开心果1 天前
【探秘 Jetpack Compose 框架深水区】 第8课:rememberSaveable 的边界在哪里?——Bundle、Saver 与什么值得跨进程存活
android·kotlin