Learn how to write server-side JavaScript programs in the Node.js runtime.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Class: Introduction to Node.js


Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. You can write JavaScript on the server, read and write from and to files and the network asynchronously, and easily spin up an http server. Several popular application frameworks are built on top of Node.js, including Express and Meteor.

What's in this class?

  • Introduction to Node.js - Node.js is a runtime - code that runs other code - that embeds the Chrome V8 JavaScript engine to let us run JavaScript programs anywhere, even without a browser. Learn how to install Node.js, then about it's key features like asynchronous IO. You'll see how the Node.js package system works, and how the technology is governed. Finally, we'll write a simple Node.js program and play with the Node.js shell.

  • Programs and Modules - You run one main Node.js file - your program. The program then requires other modules that it needs for functionality. So modules are a way of organizing code. Modules are separate JavaScript files that can export a function or an object of function properties. In this video you'll learn how to require a module by file path. Then you'll see how to require and use a built-in module like the fs filesystem module.

  • Built-In Modules - Node.js comes with several built-in modules that provide a ton of functionality like writing files and creating servers. Learn how to use these built-in modules and understand their documentation. Each module has a stability level, list of functions and examples of how to use the methods.

  • Asynchronous IO - Asynchronous IO let's us read or write files and network sockets in parallel with the rest of our code. All we have to do is provide a callback function. Learn how to use asynchronous functions by playing with the writeFile and readFile methods of the fs module. Provide a callback that takes an error and result parameter.

  • Build a Simple HTTP Server - One of the cornerstone Node.js examples is to spin up a simple http server. It's the http foundation for higher level frameworks like Express or Meteor. In this video we'll create a simple http server using the http module and the createServer method. Then we'll send it some test requests using the curl program.

  • Event Handling - Classes in Node.js can be "Event Emitters" which means we can listen and respond to certain events, just like we can in browser programming. For example, the http class provides a connection event that we can attach listeners to. In this example we'll attach an event listener for the connection event. Then we'll attach an event listener to the finish event of the response.

  • The npm Package System - Node.js gives us the module system. But we still need a way to publish and use modules built by other people. The npm package system is a server and command line tool. The server hosts almost 200,000 packages written by people around the world. The command line tool lets us use these packages and even publish our own. In this video we'll install the express web framework package. You'll see where the package is installed and how we can use it in our main program.