【发布时间】:2020-10-05 04:45:55
【问题描述】:
我的 knex 文件:
import knex from 'knex';
import path from 'path';
const dotenv = require('dotenv').config();
interface KnexConfig {
[key: string]: object;
}
const config: KnexConfig = {
developement: {
client: 'pg',
connection: {
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASS,
database: process.env.DB_NAME,
},
pool: {
min: 2,
max: 10,
},
migrations: {
directory: path.resolve(__dirname, 'src', 'infra', 'knex', 'migrations'),
},
timezone: 'UTC',
useNullAsDefault: true,
},
};
const KnexInstance = knex(config['development'] as knex.Config);
module.exports = KnexInstance;
我的迁移目录是:src/infra/knex/migrations: 我的文件夹结构:
我的 tsconfig:
{
"compilerOptions": {
"target": "es2020",
"module": "CommonJS",
"allowJs": true,
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"strictPropertyInitialization": false,
"moduleResolution": "node",
"baseUrl": "./src",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"forceConsistentCasingInFileNames": true,
"noImplicitAny": true,
"typeRoots": ["node_modules/@types", "@types"],
"paths": {
"@modules/*": ["modules/*"],
"@infra/*": ["infra/*"],
"@config/*": ["config/*"]
}
},
"include": ["src", "__tests__"],
"exclude": ["node_modules"]
}
我在 yarn knex 上收到此错误:
yarn knex migrate:make add_custom_functions
错误:
需要外部模块 ts-node/register (node:10600) UnhandledPromiseRejectionWarning:TypeError:无法读取属性 未定义的“客户” 在 Object.Knex [默认] (C:\Users\spiriT\ms-emasa\node_modules\knex\lib\knex.js:22:42)
【问题讨论】:
-
"发展" != "发展"
标签: typescript knex.js