GoConqr has a new look! Let us know what you think.

Module 9 of 14 · Text

Important Core Modules

Tomas Katz

  • path
    • path.normalize
    • path.join
    • path.dirname, path. basename, path.extname
  • fs (file-system)
  • os (operating-system)
  • util (general utilities)
    • util.inherits
    • util.log
    • util.isArray
    • util.isDate
    • util.isError
  • require (function)
  • events
  • stream
    • stream.Readable
    • stream.Writebale
    • stream.Duplex
    • stream.Transform
    • NOTE! all the above inherit from Stream which you should not use directly.
    • NOTE! Stream inherits from EventEmitter

 

 

Requiring a module steps made by node

Then the follow is the logic followed by Node.js for a require('something') statement:

• If something is a core module, return it.
• If something is a relative path (starts with ‘./’ , ‘../’) return that file OR folder.
• If not, look for node_modules/filename or node_modules/foldername each level up until you
find a file OR folder that matches something.


When matching a file OR folder:, follow these steps:
• If it matched a file name, return it.
• If it matched a folder name and it has package.json with main, return that file.
• If it matched a folder name and it has an index file, return it.
 

Instructions

You must submit an attempt for this quiz to progress. You can submit it after the last question.

Go to the chosen module

Feedback

What is it about?

What do you think of the new look?

How do you like it?