Today's Overview:
Hello again, everyone! ❤️❤️ Hope you're all doing great! Today, I started by watching some frontend design tutorials and discovered a fantastic video on YouTube by Olivier Larose. I’m planning to incorporate some of those ideas into my portfolio website. Later, I shifted focus to my advanced web course, diving into Node.js modules. Here are a few topics I covered today.
Node.js module
Node.js module is essentially a set of JavaScript functions or objects that can be included in an application. Node modules enable you to break up your code into smaller, reusable pieces. There are three main types of Node modules:
- Core Modules: These are built into Node.js and provide essential functionality, such as fs (file system), http (HTTP server/client), path, url, and more. You can access these modules without installing them by using require():
const fs = require('fs');
- Local Modules: These are custom modules created within your project.You can define and export a function or an object in a file and then import it into another file.
// File: myModule.js
module.exports = function() {
console.log("This is a custom module!");
};
// File: app.js
const myModule = require('./myModule');
myModule();
- Third-Party Modules:
These are modules written by others and published on the npm (Node Package Manager) registry. You can install them with
npm install <module-name>
and import them into your code.
// Installing and requiring Express
// Terminal: npm install express
const express = require('express');
Next, I explored the most frequently used core modules in Node.js and created a blog post to share insights on them. Here’s the link!
5 Most Used Core Modules of Node.js
That sums up all the new knowledge I gained today! hope to talk to you soon have a great day.
Top comments (0)