HTML and CSS Reference
In-Depth Information
Appendix E. Setting up Node.js
This appendix is provided for readers who need to set up Node.js for the chapter 4 applic-
ation. You might be wondering why we chose Node.js. There are several alternative web
servers that are much better suited to WebSockets than the traditional choices of Apache or
IIS (IIS8 will have built-in WebSocket support). These servers share connections between
threads, taking advantage of the mostly idle nature of event-driven connections. In chapter
4 , you'll be using Node.js for two reasons:
• It uses JavaScript, which you're already familiar with.
• It has an easy-to-use library implementing the WebSocket protocol.
This appendix will walk you through installing and setting up Node.js for the chapter 4 ap-
plication. You'll also learn how to build basic web applications with Node.js and how to use
the Node Package Manager (NPM). NPM lets you easily install modules to extend the func-
tionality of Node. You'll also create a simple application to confirm that the modules are
installed correctly.
E.1. Setting up Node.js to serve web content
Node.js is an event-driven web server based on the V8 JavaScript engine, which is part of
the Google Chrome browser. The basic process for installing Node is to download the source
code and compile it. For Linux and Unix users, this isn't an unfamiliar approach, but this
may come as a bit of a shock to Windows users. For Windows, a prebuilt binary is available
from the installation page: .
Even if you're using the prebuilt binaries, the prerequisites mentioned on the installation
page are still required because they're used in the installation of modules (which you'll look
at in E.2). Unfortunately, the installation page doesn't do a very good job of explicitly stating
the requirements for each platform; table E.1 summarizes the prerequisites for all the major
Search WWH ::

Custom Search