Slides

Install a dev dependecy with --save-dev or -D flag. The package lock keeps track of the versions of the different dependencies. Exporting and importing modules can be done with module.exports i.e.:

//in person.js
const person = {
    name: 'Joe',
    age: 33
}

module.exports = person

//in index.js
const person = require("./person");

Why not ES6? Node hasn't implemented import Person from "./person".

Path Module:

path.join(__dirname, 'test', 'hello.html')
//returns ../dirname/test/hello.html

Operating system:

const os = require("os");

console.log(os.platform());

//cpu architecture
console.log(os.arch());

//cpu core
console.log(os.cpus());

// free and total memory
console.log(os.freemem(), os.totalmem());

Event Emitter:

//in a nodejs project

const EventEmitter = require("events");

//Create class
class MyEmitter extends EventEmitter {}

//Init object
const myEmitter = new MyEmitter();

//Event listener
myEmitter.on("event", () => console.log("Event fired"));

//Init event
myEmitter.emit("event");