express - DEP0018 带快速 API
问题描述
我使用带有 typeorm 数据库的 express API 获取此错误代码:
(node:23162) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:5432
at Object._errnoException (util.js:1022:11)
at _exceptionWithHostPort (util.js:1044:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1198:14)
(node:23162) 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: 1)
(node:23162) [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.
我在我的 app.ts 中只使用了这个基本代码,并且在 sudo npm run build && sudo npm run start 之后错误仍然存在
createConnection().then(connection => {
console.log("Try");
});
我也尝试将连接更改为异步,但仍然无法正常工作。
解决方案
无论出于何种原因,您根本无法连接到数据库。这不是 ORM 本身的问题。检查您的配置,因为这绝对是问题所在。
推荐阅读
- flutter - Flutter web 元素抛出 elementnotInteractable 异常
- powershell - 是否有可能在 xcopy 命令的排除参数中传递变量
- python - 检查哪个小数更大 django
- php - 通过 CLI 使用 Imagick (PHP) 和 ImageMagick 的标准偏差值不一致
- swiftui - 如何传递绑定属性的初始值?
- php - 如何在 CodeIgniter 中使用 salt 正确实现加密库?
- php - 更改 WordPress Post 永久链接结构并获得 404 错误 nginx
- javascript - tomTomMap.addSource() 中的“归因”键是什么?
- visual-studio-code - 如何从下载的 .tar.gz 文件安装 VSCodium
- apache - 查询字符串参数在友好 url 上的位置