Create library



examples/basic/lib.js
function say_hi(name) {
    console.log('Hello ' + name)
}

console.log('Loading module')

module.exports.say_hi = say_hi;

examples/basic/app.js
const lib = require('./lib')

console.log('Hello World')

lib.say_hi('Foo')

$ node examples/basic/app.js

Loading module
Hello World
Hello Foo

It is better to define as constant so we won't change it by mistake