我一步一步地遵循教程,当我进入运行npx mikro-orm migration:create
的部分时,我得到了这个错误
TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of type string or an instance of Buffer, TypedArray, DataView, or KeyObject. Received null
at prepareSecretKey (internal/crypto/keys.js:322:11)
at new Hmac (internal/crypto/hash.js:113:9)
at Object.createHmac (crypto.js:147:10)
at createHMAC (C:lireddit-servernode_modulespglibsasl.js:133:17)
at Hi (C:lireddit-servernode_modulespglibsasl.js:137:13)
at Object.continueSession (C:lireddit-servernode_modulespglibsasl.js:32:24)
at Client._handleAuthSASLContinue (C:lireddit-servernode_modulespglibclient.js:248:10)
at Connection.emit (events.js:314:20)
at Connection.EventEmitter.emit (domain.js:483:12)
at C:lireddit-servernode_modulespglibconnection.js:109:12
at Parser.parse (C:lireddit-servernode_modulespg-protocolsrcparser.ts:102:9)
at Socket.<anonymous> (C:lireddit-servernode_modulespg-protocolsrcindex.ts:7:48)
at Socket.emit (events.js:314:20)
at Socket.EventEmitter.emit (domain.js:483:12)
at addChunk (_stream_readable.js:298:12)
at readableAddChunk (_stream_readable.js:273:9)```
I can't find any solution on google, and the tut doesn't point out how to login to postgresql on the app
您缺少一些配置,很可能是user
或password
字段。以下是相关问题:
https://github.com/mikro-orm/mikro-orm/issues/866
如果你不提供它们,MikroORM将为给定的驱动程序选择默认值,即postgres
用户和空密码——你的postgres安装显然没有这个用户的空密码。
如果您使用docker来创建postgres服务器,这就是您可以让它接受空pws:的方法
postgre:
image: postgres:12.4
ports:
- 5432:5432
environment:
POSTGRES_HOST_AUTH_METHOD: trust <-- here
您似乎没有指定要在MikroORM.init
内部传递的对象的password
或user
属性。
这应该工作
export default {
entities: [Entity],
dbName: "yourDatabaseName",
type: "postgresql",
user: "yourUserName",
password: "yourPassword"
} as Parameters<typeof MikroORM.init>[0];