Full-Stack Web Development with Vue.js and Node

(singke) #1
Building an Express Application Chapter 2

When we type that URL in our browser, we should be able to see this:


That's how Node.js works as a server program.


To exit the node console, press Ctrl + C twice.


Node.js modules


A Node.js module is just a plain JavaScript file that consists of reusable code. Every module


has its own specific functionality. We can think of it as a library.


For example, if we want to segregate all our user-related activities in our application, we
create a module for it, which will handle all the data libraries about the users.


The way we use a module in Node.js is via require. The example we just showed you


about creating a web server is also a Node.js module.


Node.js core modules

There are two types of modules in Node.js. The core modules are the modules that are built


in Node.js. They come in while we install Node.js. These are also called built-in modules.


There are a lot of core modules in Node.js:


Debugger
Filesystem
HTTP
Path
Free download pdf