Chapter 6

Intro to Node.js

If you've read anything about web development in the past couple years, you've certainly heard a lot about Node.js. But why all the hype? It seems clear at this point that Node is more than a fad, so why are so many developers excited about Node?

In this chapter you learn what Node is good for, which is directly related to how it works internally. You also learn about the differences between Node and client-side JavaScript, as well as strategies for coming into Node from the frontend. Next you install Node and build your first Node app. You learn how to use the Node REPL, and about Node's module system and installing third party modules using NPM. Finally, you learn about some general patterns and best practices in Node, including:

• Global variables and scope across modules

• Asynchronous and synchronous functions

• Streams

• Custom events and event handlers

• Child processes

Why Node?

It's no accident that Node became so popular. So many people are talking about Node because it's an excellent solution for building many modern web apps. Node is a great fit for apps with heavy input / output (I/O) and light computation. That means you should use Node if your app relies on heavy communication between the server and client, but doesn't need to do anything too complex on the server-side.

Using Node with Real-Time Apps

You've probably heard about Node in relation to “real-time” apps, such as collaborative document editors. That's because ...

Get JavaScript Programming: Pushing the Limits now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.