[node.js] How to get a variable from a file to another file in Node.js

Here is my first file:

var self = this;
var config = {
    'confvar': 'configval'
};

I want this configuration variable in another file, so I have done this in another file:

conf = require('./conf');
url = conf.config.confvar;

But it gives me an error.

TypeError: Cannot read property 'confvar' of undefined

What can I do?

This question is related to node.js

The answer is


File FileOne.js:

module.exports = { ClientIDUnsplash : 'SuperSecretKey' };

File FileTwo.js:

var { ClientIDUnsplash } = require('./FileOne');

This example works best for React.