带有express API的DEP0018

带有express API的DEP0018,express,typeorm,Express,Typeorm,我使用带有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.afterC

我使用带有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运行build&&sudo npm运行start之后,错误仍然存在

createConnection().then(connection => {
    console.log("Try");
});

我还尝试将连接更改为异步,但仍然无法工作。

无论出于何种原因,您都无法连接到数据库。这不是ORM本身的问题。检查您的配置,因为最确定的是问题所在。

您使用的是哪个数据库,mysql、postgres?我使用的是postgres数据库您启动了数据库服务器吗?是的,ormconfig.json应该有问题吗?