New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mikro orm config error key is null #866
Comments
Not sure what is wrong, but this has nothing to do with MikroORM, the error is thrown from |
Looking at the source code of What versions are you using? How does your package.json look like? Are you able to connect to your database with 3rd party tool (like pg-admin, phpmyadmin, adminer, etc...)? |
How does the full config look like? Maybe you are using wrong fields (e.g. export interface ConnectionOptions {
dbName?: string;
name?: string;
clientUrl?: string;
host?: string;
port?: number;
user?: string;
password?: string;
charset?: string;
multipleStatements?: boolean; // for mysql driver
pool?: PoolConfig;
} Doing import { Options } from '@mikro-orm/core'; // `Options` is what you want, no need to get the type from init method
const config: Options = { ... };
export default config; |
Well this is how my config looks like:
|
Can you share (for future readers) what was the issue? I guess you were missing a password in your config, and it was required by your postgres server? |
not OP, had the exact same error when I omitted "password" from config, As mentioned it has nothing to do with Micro-orm |
import { Options } from '@mikro-orm/core';
const config: Options = {
migrations: {
path: path.join(__dirname, "./migrations"), // path to the folder with migrations
pattern: /^[\w-]+\d+\.[tj]s$/, // regex pattern for the migration files
},
entities: [Post],
dbName : 'lireddit',
type: 'postgresql',
password: "s3xy",
debug: !__prod__,
};
export default config; worked for me, I was missing password. |
@sleepybyte23 but when I tried to put the password as a env variable by using process.env.PASSWORD! for example I get the same issue |
Unsure what you are exactly trying, without any context it is hard to tell. If you are trying environment variables please check the documentation. https://mikro-orm.io/docs/configuration/#using-environment-variables For other questions you could use the discussion feature on GitHub, try the mikroorm slack or stackoverflow. GitHub issues are for bugs, improvements or feature requests, not for support. If you truly believe you found a bug, then open a new issue with a full bug report, issue template and reproduction. |
@Langstra I tried to put the password in
And use it in the config file like this: import { Options } from '@mikro-orm/core';
const config: Options = {
migrations: {
path: path.join(__dirname, "./migrations"), // path to the folder with migrations
pattern: /^[\w-]+\d+\.[tj]s$/, // regex pattern for the migration files
},
entities: [Post],
dbName : 'lireddit',
type: 'postgresql',
password: process.env.PASSWORD,
debug: !__prod__,
};
export default config; And I get this:
|
You need to initialize |
Thanks for the info |
Describe the bug
I'm trying to setup mikro orm and connect to postgresql but following error pop up:
TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of type string or an instance of Buffer, TypedArray, DataView, or KeyObject. Received null
Stack trace
[discovery] ORM entity discovery started, using ReflectMetadataProvider
[discovery] - processing entity Post
[discovery] - entity discovery finished, found 1 entities, took 12 ms
internal/crypto/keys.js:304
throw new ERR_INVALID_ARG_TYPE(
^
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:304:11)
at new Hmac (internal/crypto/hash.js:113:9)
at Object.createHmac (crypto.js:143:10)
at createHMAC (C:\Users\earth\Desktop\FullStack\node_modules\pg\lib\sasl.js:133:17)
at Hi (C:\Users\earth\Desktop\FullStack\node_modules\pg\lib\sasl.js:137:13)
at Object.continueSession (C:\Users\earth\Desktop\FullStack\node_modules\pg\lib\sasl.js:32:24)
at Client._handleAuthSASLContinue (C:\Users\earth\Desktop\FullStack\node_modules\pg\lib\client.js:248:10)
at Connection.emit (events.js:315:20)
at Connection.EventEmitter.emit (domain.js:483:12)
at C:\Users\earth\Desktop\FullStack\node_modules\pg\lib\connection.js:109:12 {
code: 'ERR_INVALID_ARG_TYPE'
}
[nodemon] app crashed - waiting for file changes before starting...
Mikro ORM Config
export default { migrations: { path: path.join(__dirname, "./migrations"), pattern: /^[\w-]+\d+\.[tj]s$/, }, entities: [Post], dbName: "new-stuff", type: "postgresql", debug: !__prod__, } as Parameters<typeof MikroORM.init>[0];
The text was updated successfully, but these errors were encountered: