Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Create library

  • require
function say_hi(name) {
    console.log('Hello ' + name)
}

console.log('Loading module')

module.exports.say_hi = say_hi;
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