Learn
We will continue learning Node.js in this lesson by going into depth, covering modules essential to back-end development with Node.js. We’ll cover core Node.js modules such as events
, error
, buffer
, fs
, and timer
modules. We will also learn how to get user input and output and create readable and writable streams. These topics will not only help you get a deeper understanding of Node.js but will also build on the topics that have been covered thus far.
Instructions
Review the code in app.js. To see the outputs of the code, type node app.js
in the terminal and press Enter or Return. When you are ready to move on, click “Next”.
Here are some things that are going on in the code:
- The
events
module providesEventEmitter
objects used to assign listener functions triggered on specified events. - The
buffer
module is used to handle binary data. In app.js, aBuffer
object is being created and then converted to a string. - The
fs
module is used to interact with the user’s filesystem. In app.js, a statement is logged that verifies that a file was provided in a callback function. - The
timer
module provides thesetImmediate()
function which runs immediately after the current poll phase is completed. Take note of when'Welcome to Node.js'
is logged to the terminal.
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.