Core concepts
How do modules work?
basically, exports is an object which you can attach properties/methods to, just like any other object.. but the require function will parse a file and bind a matching keyword to a variable.
// lib.js
function sayHi () { return 'Hi' }
exports.sayHi = sayHi
// or..
exports.sayHi = function () { return 'Hi' }
// main.js
const sayHi = require('./lib').sayHi
You're simply accessing that property on the global object, module.exports (or exports, which its aliased to.)
NPM / Using Community Modules and Publishing To NPM
CLI
Processes
Asynchronous functions
- Promises
- Callbacks
- Async/Await
- Generators
- Fibers/Coroutines
Node Debugger
Core modules (assert, crypto, http, event emitters)
Core concepts
How do
moduleswork?basically,
exportsis an object which you can attach properties/methods to, just like any other object.. but therequirefunction will parse a file and bind a matching keyword to a variable.You're simply accessing that property on the global object,
module.exports(orexports, which its aliased to.)NPM / Using Community Modules and Publishing To NPM
CLI
Processes
Asynchronous functions
Node Debugger
Core modules (assert, crypto, http, event emitters)