Chapter 2. The basics of Node.js

This chapter covers

  • Installing Node.js and using its module system
  • Using package.json to describe your project’s metadata
  • Using npm to install packages with npm install
  • Doing two things at once with Node
  • Using Node’s built-in http module to build a simple web server

In chapter 1, we described Node.js, explaining that it’s JavaScript, asynchronous, and has a rich set of third-party modules. If you’re like me, you didn’t totally understand these things when you first started with Node. This chapter aims to give the intro to Node that I wish I had: short and sweet. (From here forward, I’ll refer to Node.js simply as Node.)


I’m assuming that you know a fair bit of JavaScript and that you don’t ...

Get Express in Action: Writing, building, and testing Node.js applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.