请帮助修复 mongoDB/node.js
events.js:174
throw er; // Unhandled 'error' event
^
MongoTimeoutError: Server selection timed out after 30000 ms
at Timeout.setTimeout (E:\Digital\PROJECT\digital-api\node_modules\mongojs\node_modules\mongodb\lib\core\sdam\topology.js:878:9)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
Emitted 'error' event at:
at E:\Digital\PROJECT\digital-api\node_modules\mongojs\lib\database.js:36:16
at err (E:\Digital\PROJECT\digital-api\node_modules\mongojs\node_modules\mongodb\lib\operations\execute_operation.js:76:14)
at executeCallback (E:\Digital\PROJECT\digital-api\node_modules\mongojs\node_modules\mongodb\lib\operations\execute_operation.js:67:25)
at err (E:\Digital\PROJECT\digital-api\node_modules\mongojs\node_modules\mongodb\lib\operations\connect.js:192:23)
at connectCallback (E:\Digital\PROJECT\digital-api\node_modules\mongojs\node_modules\mongodb\lib\operations\connect.js:343:5)
at topology.connect.err (E:\Digital\PROJECT\digital-api\node_modules\mongojs\node_modules\mongodb\lib\operations\connect.js:471:14)
at selectServer (E:\Digital\PROJECT\digital-api\node_modules\mongojs\node_modules\mongodb\lib\core\sdam\topology.js:258:11)
at selectServers (E:\Digital\PROJECT\digital-api\node_modules\mongojs\node_modules\mongodb\lib\core\sdam\topology.js:412:25)
at Timeout.setTimeout (E:\Digital\PROJECT\digital-api\node_modules\mongojs\node_modules\mongodb\lib\core\sdam\topology.js:877:7)
at ontimeout (timers.js:436:11)
[... lines matching original stack trace ...]
at Timer.processTimers (timers.js:223:10)
答案1
我认为您的 npm mongojs 版本存在问题。mongojs 3.3.3 npm 中有一个错误。您安装了 mongojs3.3.3。
需要在终端中按照以下步骤操作。
rm -rf mongojs or npm uninstall mongojs
npm install [email protected]