我正在尝试同时运行客户端和服务器端应用程序,但未成功。基本上,我在客户端应用程序(reactjs)上运行build,然后将所有文件从build文件夹复制到服务器端工作所在的client / build文件夹。一切正常,直到我在客户端工作上进行了一些更改,然后重建并更新了服务器文件夹。我不太清楚有关该错误消息的信息...这是我的错误日志
[0] > node app.js
[0]
[0] (node:2907) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
[0] events.js:167
[0] throw er; // Unhandled 'error' event
[0] ^
[0]
[0] Error: listen EADDRINUSE :::3000
[0] at Server.setupListenHandle [as _listen2] (net.js:1286:14)
[0] at listenInCluster (net.js:1334:12)
[0] at Server.listen (net.js:1421:7)
[0] at Object.<anonymous> (/Users/guest/Desktop/work/copy/finfine/app.js:180:8)
[0] at Module._compile (internal/modules/cjs/loader.js:688:30)
[0] at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
[0] at Module.load (internal/modules/cjs/loader.js:598:32)
[0] at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
[0] at Function.Module._load (internal/modules/cjs/loader.js:529:3)
[0] at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
[0] at startup (internal/bootstrap/node.js:285:19)
[0] at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
[0] Emitted 'error' event at:
[0] at emitErrorNT (net.js:1313:8)
[0] at process._tickCallback (internal/process/next_tick.js:63:19)
[0] at Function.Module.runMain (internal/modules/cjs/loader.js:744:11)
[0] at startup (internal/bootstrap/node.js:285:19)
[0] at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
[0] npm ERR! code ELIFECYCLE
[0] npm ERR! errno 1
[0] npm ERR! finfine@1.0.0 start-server: `node app.js`
[0] npm ERR! Exit status 1
[0] npm ERR!
[0] npm ERR! Failed at the finfine
@1.0.0 start-server script.
[0] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[0]
[0] npm ERR! A complete log of this run can be found in:
[0] npm ERR! /Users/guest/.npm/_logs/2019-03-26T00_43_54_435Z-debug.log
[0] npm run start-server exited with code 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! finfine@1.0.0 start: `concurrently "npm run start-server"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the finfine@1.0.0 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! /Users/guest/.npm/_logs/2019-03-26T00_43_54_468Z-debug.log
答案 0 :(得分:0)
错误的症结所在于此行:Error: listen EADDRINUSE :::3000
这意味着当您运行npm run start-server
时,已经有一个服务器正在运行并在该端口上监听。您的React开发服务器是否在与服务器相同的端口(3000)上运行?
如果您使用的是macOS的较新版本,则可以使用以下命令来检查端口3000上正在运行的内容:lsof -nP -i4TCP:3000 | grep LISTEN