如何修复UnhandledPromiseRejectionWarning: TypeError? &g



所以我正在使用Express.JS和MongoDB制作web应用程序,当我尝试在本地运行它时,它可以工作,但是当我使用aws Ubuntu 20.04机器运行它时,它给了我以下错误:

(node:13452) UnhandledPromiseRejectionWarning: TypeError: [objectOptions,urlOptions,exports.DEFAULT_OPTIONS].flatMap is not a function
at parseOptions (/home/ubuntu/tylertv/node_modules/mongodb/lib/connection_string.js:258:77)
at new MongoClient (/home/ubuntu/tylertv/node_modules/mongodb/lib/mongo_client.js:62:63)
at Promise (/home/ubuntu/tylertv/node_modules/mongoose/lib/connection.js:784:16)
at new Promise (<anonymous>)
at NativeConnection.Connection.openUri (/home/ubuntu/tylertv/node_modules/mongoose/lib/connection.js:781:19)
at _mongoose._promiseOrCallback.cb (/home/ubuntu/tylertv/node_modules/mongoose/lib/index.js:342:10)
at Promise (/home/ubuntu/tylertv/node_modules/mongoose/lib/helpers/promiseOrCallback.js:32:5)
at new Promise (<anonymous>)
at promiseOrCallback (/home/ubuntu/tylertv/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:10)
at Mongoose._promiseOrCallback (/home/ubuntu/tylertv/node_modules/mongoose/lib/index.js:1181:10)
(node:13452) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:13452) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

我不知道为什么会这样,我已经安装了mongodb,npm和node。

https://www.github.com/tttylerr/tylertv

^我的源代码主要是server.js

这可能有以下几个原因:

  1. 您的AWS机器上安装了MongoDB吗?
  2. 你的本地机器和AWS机器上的Node.js/NPM/MongoDB版本不匹配吗?

注:如果在启动时发生该错误,则该错误可以解释为-"无法连接到MongoDB实例"。查看与Mongo相关的内容

相关内容

  • 没有找到相关文章

最新更新