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.