简体   繁体   中英

_.get does not work with module.exports object

I have a node file that exports an object

(path './../../config/cloud.js):

module.exports = {
   some: {
       property: 1
   }
}

if I use the following code:

const config   = require('./../../config/cloud');
const _  = require('lodash');
console.log(_.get(config, 'some.property'); // prints undefined
console.log(config.some.property); // print 1

Can you help me to see what I'm doing wrong? Thanks

EDIT: I expect that the first console.log prints 1 instead of undefined .

由于某种原因, _是未定义的,并引发了某种异常,该异常在某种程度上在我的日志中不可见。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM