Section 1

Preview this deck

Create Your Own Modules (1)

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (5)

Section 1

(5 cards)

Create Your Own Modules (1)

Front

You can create your own modules, and easily include them in your applications. The following example creates a module that returns a date and time object: Use the [ exports keyword ] to make properties and methods available outside the module file.

Back

What is a Module in Node.js?

Front

*Consider modules to be the same as JavaScript libraries. *A set of functions you want to include in your application.

Back

Include Modules

Front

To include a module, use the require() function with the name of the module:

Back

Include Your Own Module (2) Now you can include and use the module in any of your Node.js files.

Front

Notice that we use ./ to locate the module, that means that the module is located in the same folder as the Node.js file.

Back

Built-in Modules

Front

Node.js has a set of built-in modules which you can use without any further installation.

Back