Depending on your environment, Node is easy to set up or very easy to set up. Node runs on Unix-compatible systems and, more recently, Windows. The former means it runs on Macs, Linux machines, and most environments you’re likely to be developing for. There are companies offering Node hosting with all kinds of great features like monitoring tools and deployment via version control tools like Git. However, you can also install Node on any server you can SSH into where you have the ability to create files and directories.
For purposes of getting something running, let’s assume you’re installing Node locally on a Mac. We’ll highlight the differences for Windows and remote server setup as we go.
There are numerous ways to install Node itself, depending on your environment. The easiest option is to download one of the installers available for Windows or Mac from the Node website (these include npm, as well). You can also install it in one line using Homebrew or the Advance Packaging Tool. On any supported operating system, if you have Git installed, you can clone Node directly from the repository and build it yourself.
$ git clone git://github.com/joyent/node.git $ cd node $ git checkout v0.6.6 $ ./configure $ make $ make install
All we’re doing is cloning the GitHub repository, running a
configuration script, and then building and installing Node. Pay special
attention to the third line, though, because we’re also switching to the
branch containing the most recent stable version of Node. That changes
frequently, so if you decide to install from the command line, check the
Node.js website first to find out what the current stable version is, or
git tag to list available versions.
It’s no longer necessary to install npm separately, but if you need or want to for some reason, command-line installation is very straightforward. For all environments where npm is currently supported, the preferred method of installation is Curl:
$ curl http://npmjs.org/install.sh | sh
npm is Node’s package manager. It maintains a registry of Node
modules and allows one-line installation and version management of
third-party packages. You can find modules in npm from the command line
npm search .