Git安装服务端依赖时:
使用npm命令安装项目的依赖文件,
进入koa2-mongodb-jwt-server文件夹,输入:npm i
E:\html5\VS Code\Git\code\koa2-mongodb-jwt-server>npm run dev
> Pricer-Server-v2@0.1.0 dev
> nodemon src/bin/www.js
[nodemon] 2.0.22
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `babel-node src/bin/www.js`
14:05:37:659 DEBUG Creating server... (E:\html5\VS Code\Git\code\koa2-mongodb-jwt-server\src\lib\server.js:58)
14:05:38:113 DEBUG startup Server created, ready to listen (E:\html5\VS Code\Git\code\koa2-mongodb-jwt-server\src\lib\server.js:126)
14:05:38:130 DEBUG Server listening on 5001 in development mode (E:\html5\VS Code\Git\code\koa2-mongodb-jwt-server\src\bin\www.js:11)
MongoDB 连接错误: MongoServerSelectionError: getaddrinfo ENOTFOUND mongo
at Timeout._onTimeout (E:\html5\VS Code\Git\code\koa2-mongodb-jwt-server\node_modules\mongodb\src\sdam\topology.ts:564:30)
at listOnTimeout (node:internal/timers:569:17)
at processTimers (node:internal/timers:512:7) {
reason: TopologyDescription {
type: 'Unknown',
servers: Map(1) { 'mongo:27017' => [ServerDescription] },
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: null,
maxElectionId: null,
maxSetVersion: null,
commonWireVersion: 0,
logicalSessionTimeoutMinutes: null
},
code: undefined,
[Symbol(errorLabels)]: Set(0) {}
}
E:\html5\VS Code\Git\code\koa2-mongodb-jwt-server\node_modules\mongoose\lib\connection.js:755
err = new ServerSelectionError();
^
MongooseServerSelectionError: getaddrinfo ENOTFOUND mongo
at _handleConnectionErrors (E:\html5\VS Code\Git\code\koa2-mongodb-jwt-server\node_modules\mongoose\lib\connection.js:755:11) at NativeConnection.openUri (E:\html5\VS Code\Git\code\koa2-mongodb-jwt-server\node_modules\mongoose\lib\connection.js:730:11)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at runNextTicks (node:internal/process/task_queues:64:3)
at listOnTimeout (node:internal/timers:538:9)
at processTimers (node:internal/timers:512:7) {
reason: TopologyDescription {
type: 'Unknown',
servers: Map(1) {
'mongo:27017' => ServerDescription {
address: 'mongo:27017',
type: 'Unknown',
hosts: [],
passives: [],
arbiters: [],
tags: {},
minWireVersion: 0,
maxWireVersion: 0,
roundTripTime: -1,
lastUpdateTime: 405211935,
lastWriteDate: 0,
error: MongoNetworkError: getaddrinfo ENOTFOUND mongo
at connectionFailureError (E:\html5\VS Code\Git\code\koa2-mongodb-jwt-server\node_modules\mongodb\src\cmap\connect.ts:513:14)
at Socket. (E:\html5\VS Code\Git\code\koa2-mongodb-jwt-server\node_modules\mongodb\src\cmap\connect.ts:415:16)
at Object.onceWrapper (node:events:628:26)
at Socket.emit (node:events:513:28)
at Socket.emit (node:domain:489:12)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at processTicksAndRejections (node:internal/process/task_queues:82:21) {
cause: Error: getaddrinfo ENOTFOUND mongo
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'mongo'
},
[Symbol(errorLabels)]: Set(1) { 'ResetPool' }
},
topologyVersion: null,
setName: null,
setVersion: null,
electionId: null,
logicalSessionTimeoutMinutes: null,
primary: null,
me: null,
'$clusterTime': null
}
},
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: null,
maxElectionId: null,
maxSetVersion: null,
commonWireVersion: 0,
logicalSessionTimeoutMinutes: null
},
code: undefined
}
Node.js v18.14.2
[nodemon] app crashed - waiting for file changes before starting...
不知道你这个问题是否已经解决, 如果还没有解决的话: