Installing Node.js
Node.js can be easily installed by visiting the official Node website and accessing the Downloads section at http://nodejs.org/download/.
Once there, be sure to download the correct version depending on your OS and CPU (32 bit or 64 bit).
Mac OS X installation instructions
To determine which version of Node you want to download, you first need to determine your processor type: 32 or 64 bit. You can do this by executing the following command from a terminal:
$ sysctl hw | grep 64bit hw.cpu64bit_capable: 1
If you get 1
in the response, then you are running a 64-bit CPU. If the response is 0
, then you are running the 32-bit version. Fortunately, there is a universal installer specifically for Mac available from the Node website; however, if you wanted to download the binary, at least now you know which to get.
Once the download is complete, double-click on the .pkg
file, which will launch the Node installer (as shown in the following screenshot):
Proceeding through each step of the wizard should be fairly self-explanatory. Note that the installation of Node also includes the installation of npm, Node's Package Manager.
Windows 7 or 8 installation instructions
To determine which version of Node you want to download, you first need to determine your processor type; that is, 32 or 64 bit. You can do this by executing the following command on the command prompt:
$ wmic os get osarchitecture OSArchiecture 64-bit
Once the download is complete, double-click on the .msi
file that will launch the Node installer (as shown in the following screenshot):
Proceed through all the steps of the wizard. When you get to the custom setup screen, you will notice that the installation wizard will install not only the Node.js runtime, but also npm and configure a PATH variable (so that node and npm can be executed from any folder via the command line).
Linux installation instructions
As there are so many different flavors and distributions of Linux available, installing Node isn't quite straightforward. However, if you're running Linux to begin with, then you are more than aware of this and probably comfortable with a few extra steps.
To determine your CPU type, whether 32 or 64 bit, execute the following command from the command line:
$ uname -m x86_64
This command will output the chipset architecture and processor type (that is, Intel x86 with 64 bit).
Joyent has an excellent wiki on how to install Node on Linux using the many different package manager options available. You can read that wiki by visiting https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager.
For Ubuntu 12.04 to 13.04 as an example, the steps to install Node would be as follows:
$ sudo apt-get update $ sudo apt-get install python-software-properties python g++ make $ sudo add-apt-repository ppa:chris-lea/node.js $ sudo apt-get update $ sudo apt-get install nodejs
Once those steps have completed, both Node and npm should be installed on your system.
Confirming successful Node.js installation
Now that Node has been installed on your system, let's run a quick test to ensure everything is working properly.
Access the command line via your Terminal program and execute the following command:
$ node --version v0.10.26 $ npm --version 1.4.3
Assuming your Node installation was successful, you should see the version number that was installed in the output on the screen right under the command you executed.
Note
Note that your version numbers will most likely be more recent than those printed in the preceding example.
You can also launch the Node repl, a command-line shell that lets you execute JavaScript directly:
$ node > console.log('Hello world!') Hello World! Undefined [press Ctrl-C twice to exit]
Bookmarking the online documentation
Be sure to point your browser to the following online documentation for Node and bookmark it, as it will undoubtedly become a resource that you will want to access on a regular basis:
Also, check out the npm registry, outlined in the following link, where you can find tens of thousands of modules available for Node developers: