create a file like people.js
var people = ['sakib', 'tamim', 'bipon']
var a = 6;
function test(){
console.log("test")
}
Import into index.js file
const people = require('./people')
Then run into terminal by node index.js
. Showing blank {}
Update one line into people.js file
var people = ['sakib', 'tamim', 'bipon']
var a = 6;
function test(){
console.log("test")
}
module.exports = people;
Or
var people = ['sakib', 'tamim', 'bipon']
var a = 6;
function test(){
console.log("test")
}
console.log(module)
// module.exports = people;
module.exports = {
people: people,
a: a,
test: test
}
Output
If console.log(module)
then showing bellow output.
Command into terminal node people
Output
By default exports blank. exports: {}
. That's why without export showing blank value.
Top comments (0)