官术网_书友最值得收藏!

Installing Node.js

To run CoffeeScript, first you'll need to install Node.js. Don't worry! If you don't want to learn Node.js, you won't need to. We just need to have the platform installed because the CoffeeScript compiler uses it.

Tip

If you get stuck at any point while installing or using Node.js, the IRC channel is a great place to look for help. You can use your IRC client of choice to connect to the #node.js room in irc.freenode.net, or you can connect through a web browser by visiting http://webchat.freenode.net/?channels=node.js.

Node.js (or simply Node) is a platform for running JavaScript at a low level, using the powerful and fast V8 engine. It's primarily used for web development, allowing developers to write the server side components of web applications in JavaScript. Node's most notable innovation is that it's highly non-blocking. Any system call that needs to wait for a result (such as network requests and disk reads) uses a callback, so Node can service another request while it waits for an operation to finish. This way of thinking meshes nicely with web applications which do a lot of network interaction, and it provides a lot of bang for your hardware buck. While we'll be using CoffeeScript to build a client side application, it works great with Node as well. We'll show you more about that in Chapter 11, CoffeeScript on the Server. The CoffeeScript compiler is written entirely in CoffeeScript and runs on Node. If you're curious, you can find the annotated CoffeeScript source on http://coffeescript.org/.

Installing Node.js on OS X

The Node project provides several options for installation on Mac OS X. The simplest method is the universal installer. If you don't already use a package management system for your development tools, you should use the installer. If you use Homebrew or MacPorts to manage your system and would like to install Node through those, follow the instructions for your package manager instead.

Tip

If for some reason none of these methods work for you, see the Compiling Node.js manually section. However, this is more difficult and not recommended unless you really need it.

Using the installer

The Node project provides a universal installer for Mac OS X. Visit http://nodejs.org/download/, and look for Macintosh Installer.

Using the installer

Download that file and double-click on it. Follow the prompts to install Node on your system.

Using Homebrew

Homebrew is a popular package management system for OS X. It maintains installed packages in a completely separate directory from the OS X system files, and offers easy package management from the command line. Homebrew offers an easy-to-use formula system to create new package definitions, and as a result offers a very large collection of user-contributed recipes.

Note

Early versions of the Node package on Homebrew suffered from numerous bugs. Recent versions have received far fewer complaints and should be acceptable for our needs. Still, if you encounter serious problems using Node from Homebrew, consider uninstalling it and using the universal installer instead.

To install Node using Homebrew, simply use the command-line installer as follows:

brew install node

Tip

For help with Homebrew, visit the official site at http://mxcl.github.com/homebrew/.

Using Macports

MacPorts is another package management system for OS X. Like Homebrew, it maintains installed packages separately from the OS X system files. MacPorts is an older project, and is modeled on the BSD ports system. While it has been waning in popularity in recent years, it still has a large user base.

To install Node using MacPorts, simply use the command-line installer as follows:

sudo port install nodejs

Tip

For help with MacPorts, visit the official site at https://www.macports.org/.

Installing Node.js on Windows

There are several convenient installation options for Node on Windows. The method recommended for most people is to use the installer. If you cannot install software on your machine, or for other reasons wish to isolate Node, you can use the standalone executable instead. Finally, if you are already using the third-party package manager Chocolatey to manage packages on your machine, you may install Node through that system.

主站蜘蛛池模板: 祁东县| 黎平县| 嘉荫县| 南川市| 马鞍山市| 红桥区| 华宁县| 绥滨县| 广安市| 垣曲县| 宝丰县| 绵竹市| 台东市| 睢宁县| 宝兴县| 南投县| 长岭县| 类乌齐县| 阿拉善右旗| 米易县| 巫溪县| 吉水县| 德化县| 崇阳县| 京山县| 南通市| 高台县| 百色市| 石城县| 蚌埠市| 枣强县| 无棣县| 沈丘县| 克东县| 苍梧县| 澎湖县| 义乌市| 新龙县| 定远县| 临清市| 全州县|