0

我试图同时使用同时运行服务器和客户端,然后我得到了这个错误,即使我在网上尝试了很多解决方案,检查了没有 5000 端口在运行,删除模块,yarn.lock,清理缓存,重新启动我的电脑等,错误仍然存​​在。

包.json

{
  "name": "SPACEX_LAUNCH_STATS",
  "version": "1.0.0",
  "description": "App that lists SpaceX launch missions",
  "main": "server.js",
  "scripts": {
    "start": "node server.js",
    "server": "nodemon server.js",
    "client": "yarn start --prefix client",
    "dev": "concurrently \"yarn run server\" \"yarn run client\""
  },
  "author": "admin",
  "license": "MIT",
  "dependencies": {
    "axios": "^0.21.1",
    "concurrently": "^6.2.0",
    "express": "^4.17.1",
    "express-graphql": "^0.12.0",
    "graphql": "^15.5.1"
  },
  "devDependencies": {
    "nodemon": "^2.0.7"
  }
}

错误

Temps-MacBook-Pro:SPACEX_LAUNCH_STATS tempuser$ yarn run dev
yarn run v1.22.10
warning ../../../../package.json: No license field
$ concurrently "yarn run server" "yarn run client"
warning ../../../../package.json: No license field
warning ../../../../package.json: No license field
$ yarn start --prefix client
$ nodemon server.js
warning ../../../../package.json: No license field
[0] [nodemon] 2.0.9
[0] [nodemon] to restart at any time, enter `rs`
[0] [nodemon] watching path(s): *.*
[0] [nodemon] watching extensions: js,mjs,json
[0] [nodemon] starting `node server.js`
$ node server.js --prefix client
[0] Server started on port 5000
[1] node:events:304
[1]       throw er; // Unhandled 'error' event
[1]       ^
[1] 
[1] Error: listen EADDRINUSE: address already in use :::5000
[1]     at Server.setupListenHandle [as _listen2] (node:net:1286:16)
[1]     at listenInCluster (node:net:1334:12)
[1]     at Server.listen (node:net:1420:7)
[1]     at Function.listen (/Users/tempuser/Documents/React/spaceX/SPACEX_LAUNCH_STATS/node_modules/express/lib/application.js:618:24)
[1]     at Object.<anonymous> (/Users/tempuser/Documents/React/spaceX/SPACEX_LAUNCH_STATS/server.js:17:5)
[1]     at Module._compile (node:internal/modules/cjs/loader:1083:30)
[1]     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1112:10)
[1]     at Module.load (node:internal/modules/cjs/loader:948:32)
[1]     at Function.Module._load (node:internal/modules/cjs/loader:789:14)
[1]     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:72:12)
[1] Emitted 'error' event on Server instance at:
[1]     at emitErrorNT (node:net:1313:8)
[1]     at processTicksAndRejections (node:internal/process/task_queues:80:21) {
[1]   code: 'EADDRINUSE',
[1]   errno: -48,
[1]   syscall: 'listen',
[1]   address: '::',
[1]   port: 5000
[1] }
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[1] yarn run client exited with code 1

可疑的一件事是我能够杀死所有端口,但有一个是不可杀死的。它说“没有这样的过程”。我不确定这是否是隐藏在幕后某处的正在运行的端口。这是屏幕截图。请帮忙。

没有这个过程

4

1 回答 1

0

我改为 "dev": "concurrently \"yarn run server\" \"yarn run client\"" "dev": "concurrently \"npm run server\" \"npm run client\""现在一切正常。我不知道为什么,但是端口 3000 和 5000 现在都可以运行

于 2021-07-07T05:52:47.167 回答