Installing Node.js

The first thing we need to do to start developing web applications is to install Node.js, if you haven't done so already. Due to its enormous popularity, Node.js is available on practically any operating system. In this chapter, however, we will focus on installing it on Linux and OS X as these are the only officially supported platforms by RethinkDB.

For further information on Node.js and the platforms it supports, you can visit its website at https://nodejs.org/en/ where you will find package installers for your operating system and links to Node's GitHub repository if you prefer compiling the source code.

Installing on Linux

If you are running a Linux-based operating system, in most cases, you should be able to install Node.js using your distribution's package manager.

For example, if you're running the latest LTS version of Ubuntu Linux, you can install Node.js by running the following commands from the terminal:

curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs

The first command will download and run a bash script that will configure Node's repository, whereas the second command will install Node.js on your system. If the installation succeeds, you will get an output similar to this:

Reading package lists... DoneBuilding dependency treeReading state information... DoneThe following NEW packages will be installed:
nodejs0 upgraded, 1 newly installed, 0 to remove and 32 not upgraded.Get:1 https://deb.nodesource.com/node_4.x/ trusty/main nodejs amd64 4.2.2-1nodesource1~trusty1 [6,782 kB]
Selecting previously unselected package nodejs.(Reading database ... 77181 files and directories currently installed.)
Preparing to unpack .../nodejs_4.2.2-1nodesource1~trusty1_amd64.deb ...Unpacking nodejs (4.2.2-1nodesource1~trusty1) ...Processing triggers for man-db (2.6.7.1-1ubuntu1) ...Setting up nodejs (4.2.2-1nodesource1~trusty1) ...

This output confirms that the installation was successful.

If you're running a Linux distribution that uses the yum package manager, the commands will be slightly different. You can install Node on your system by running this:

curl --silent --location https://rpm.nodesource.com/setup | bash -
yum -y install nodejs

Just as before, the first command will install and configure Node's repository on your system, and the second command will install Node.js.

Installing on Mac OS X

If you're using Mac OS X, the installation process gets much easier as you can install Node using an install wizard or the Brew package manager.

First, head to https://nodejs.org/en/download/ and download the Macintosh installer by clicking on the appropriate link. Once the download has finished, run the installer to start the installation wizard, which will look as this:

Installing on Mac OS X

Follow the instructions provided by the installation wizard, which will prompt you for your user password before starting the installation. Once the install wizard has finished, you'll get a confirmation window confirming that Node.js has been successfully installed on your system:

Installing on Mac OS X

Congratulations! By now, you should have Node.js installed and configured on your system.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.14.196