简体   繁体   English

如何修复 UnhandledPromiseRejectionWarning: TypeError?

[英]How to fix UnhandledPromiseRejectionWarning: TypeError?

So I am making a web app using Express.JS and MongoDB and when I try to run it locally, it works, but when I run it with my aws Ubuntu 20.04 machine it gives me the following error:所以我正在使用 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.

I have no clue why this is doing this all I have installed is mongodb,npm, and node.我不知道为什么这样做我安装的是 mongodb、npm 和节点。

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

^ My source code is server.js mainly ^ 我的源代码主要是 server.js

This could happen by several reasons:这可能有以下几个原因:

  1. Do you have MongoDB installed on you AWS machine?你的 AWS 机器上安装了 MongoDB 吗?
  2. Do versions of Node.js/NPM/MongoDB mismatch on your local machine and on AWS machine?本地机器和 AWS 机器上的 Node.js/NPM/MongoDB 版本是否不匹配?

PS If that error occurs on startup, then the error can be interpreted as - "Couldn't connect to MongoDB instance". PS 如果该错误发生在启动时,则该错误可以解释为 - “无法连接到 MongoDB 实例”。 Check that stuff related to Mongo.检查与 Mongo 相关的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 节点和 DialogFlow 错误:UnhandledPromiseRejectionWarning:TypeError:sessionClient.projectAgentSessionPath 不是 function - Node and DialogFlow Error: UnhandledPromiseRejectionWarning: TypeError: sessionClient.projectAgentSessionPath is not a function 如何修复“Uncaught TypeError: db.collection is not a function”? - How to fix "Uncaught TypeError: db.collection is not a function"? 无法修复“Uncaught TypeError: posts.map is not a function”错误 - Cannot fix "Uncaught TypeError: posts.map is not a function" error 如何修复 AccessDenied 调用 CopyObject - How to fix AccessDenied calling CopyObject 如何修复 Lambda 预热(冷启动修复)使用 CDK 和 Typescript - How to fix Lambda Warmup (Cold Start fix) Using CDK and Typescript 如何修复 firebase“找不到命令”错误 - how to fix firebase "command not found" error 如何修复 AWS lambda 中的“exec 格式错误” - How to fix "exec format error" in AWS lambda 如何修复 Google oauth 验证错误 - How to fix Google oauth verification error 如何修复数据未插入本地 dynamodb (NodeJS) - How to fix data not inserting into local dynamodb (NodeJS) Pyspark 读取 jdbc 给出错误。 怎么修? - Pyspark read jdbc giving errors . How to fix?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM