Create a Simple Node.js Module

InstructorWill Button

Share this video with your friends

Send Tweet

In this lesson, we introduce modules: what they are and how to use them. You'll learn: how to create a simple module and export the functions to be accessed elsewhere how to include code from your module in files within your application the three rules node uses to find the modules you require the hierarchy node uses to determine which modules take precedence which file extensions node can automatically detect when requiring modules

tep
~ 7 years ago

If we use: var colors = require('colors') And in my folder has following file: /colors.js /node_modules/colors

Which one is treated as require object?

Will Buttoninstructor
~ 7 years ago

Take a look at this. It should explain it: https://nodejs.org/api/modules.html#modules_all_together