Modules in NodeJS

What is a module?

Simply put, modules are files that contain code.

In Node, you use modules all the time to build up the functionality of your server-side code. 

This concept is similar to the use of CDNs where you create an HTML file and then start adding script/link tags to give yourself more tools to use. 
In Node, you create a new Node environment, then install or create modules to give yourself new functionality. One difference though is that you actually install/or create Modules unlike CDNs where you only load it in the browser.

The 3 types of modules

Core Modules

File Modules

Node Modules

These are modules that exist by default in Node. You don't need to install, you can simply "require" them to use them.

These are modules you create yourself. Your files with your code that you can pull in ("require") to other files to use.

These are the modules you install from NPM. After you install them into your Node environment, you can "require" them to use them.

Demonstration

Exercise

Use 1 of each type of module 
(Core, File, Node)

Explain each type of module and their benefits in the WRITEHERE.md file.
Then make a pull request to turn in your answers and show the code you wrote

Watch the videos in workbook(if available) for this learning experience and read the summary of both videos

Fork and clone this repo: 

https://github.com/gSchool/nodeModules

NodeJS

By Akyuna Akish

NodeJS

  • 1,129