简体   繁体   English

为什么会收到此错误类型错误:无法读取未定义的属性“客户端”

[英]Why am getting this error TypeError: Cannot read property 'client' of undefined

if (arguments.length === 0 || !config.client && !config.dialect) {
                                    ^

TypeError: Cannot read property 'client' of undefined类型错误:无法读取未定义的属性“客户端”

Why am I getting this error?为什么我收到这个错误?

The config variable is undefined . config变量是undefined You should check it to before reading the values of config.client and config.dialect你应该在阅读config.clientconfig.dialect的值之前检查它

if (arguments.length === 0 || (config && !config.client && !config.dialect))

Keep in minds that if config is undefined , the evaluation of the right expression in the OR clause will be false请记住,如果 config undefined ,则OR子句中正确表达式的计算结果将为 false

I was running into this issue as well.我也遇到了这个问题。 In my code I'm initializing knex in the following way.在我的代码中,我按以下方式初始化 knex。

const knex = require('knex')(process.env.DATABASE_URL)

When I checked the value of process.env.DATABASE_URL I discovered that it was undefined.当我检查process.env.DATABASE_URL的值时,我发现它是未定义的。 Once I fixed that, the error went away!一旦我解决了这个问题,错误就消失了! (In my case I had my .env file in the wrong place) (就我而言,我的 .env 文件放错了地方)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我为什么会收到TypeError:无法读取未定义的属性“现在” - Why am I getting TypeError: Cannot read property 'now' of undefined 为什么我收到“ TypeError:无法读取未定义的属性” length” - Why am I getting 'TypeError: Cannot read property 'length' of undefined' 为什么我收到此错误:未捕获的TypeError:无法读取undefined的属性'john' - Why am I getting this error: Uncaught TypeError: cannot read property 'john' of undefined 为什么我收到错误:类型错误:无法读取未定义的属性“地图”? - Why am I getting an error : TypeError: Cannot read property 'map' of undefined? 为什么我收到错误“UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'forEach' of undefined”? - Why am I getting the error “UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'forEach' of undefined”? 我为什么会收到错误:Uncaught TypeError:无法读取未定义的属性“ left” - Why am I getting the error: Uncaught TypeError: Cannot read property 'left' of undefined 为什么我收到此错误:“未捕获的TypeError:无法读取未定义的属性'标题'”? - Why am i getting this error: “Uncaught TypeError: Cannot read property 'Title' of undefined”? 为什么我会出错? 类型错误:“无法读取未定义的属性‘执行’” - Why am I getting error? TypeError: “Cannot read property 'execute' of undefined” 为什么我会收到 TypeError: Cannot read property '0' of undefined error in google apps script? - Why am I getting TypeError: Cannot read property '0' of undefined error in google apps script? 为什么我越来越无法读取未定义错误的属性? - why I am getting, cannot read property of undefined error?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM