Installing the RethinkDB module

Usually, platforms such as Node.js are simple and minimal by design; this is why most of these platforms have some sort of system that allows you to download, install, and manage third-party extension packages called modules. For example, in Python, you have pip or easy install. In Node, you have NPM—the Node Package Manager.

NPM is both a package manager to install and remove modules from the system and a standard to define dependencies on other packages. It also provides a public registry service that contains all the Node.js modules that developers want to publish through NPM.

The RethinkDB module is also hosted on NPM, and we will use Node's package manager to install it.

Before attempting to install the module, you should check to see if NPM is installed on your system. If you have installed Node.js by following the instructions in the previous section of this chapter, you will already have NPM installed on your machine. If, however, you have installed Node.js by compiling the source code, you might not have the package manager installed. If this is the case, you must install it now, and you can do so by following the software's documentation (https://github.com/npm/npm).

You can check if you have NPM installed on your system by running the following command:

npm –v

If it is installed, this command will display the version of NPM installed.

Now that we've verified that Node's package manager is indeed installed, we can finally install RethinkDB's module. To install a module using NPM, you just need to run the npm command followed with the library's name as its parameter.

As you can imagine, RethinkDB's module is called rethinkdb, so we can install it by executing the following command from the terminal:

sudo npm install rethinkdb

This command will download the requested package and its dependencies, and it will install them into the node_modules directory.

It's useful to know that NPM can operate in two modes: global and local. By default, NPM works in a local mode; in this mode, it installs everything inside the current working directory, usually your project's root directory, without touching any system global settings. This is the recommended way of using the package manager as it allows you to choose which modules and versions to install on a per-application basis. If, however, you prefer to install packages globally, you can do so by enabling global mode, by passing the -g parameter when installing a package.

For example, this command will install the RethinkDB module globally:

sudo npm install –g rethinkdb

The exact location where NPM installs global packages depends on your distribution and configuration, although the default location is /usr/local/lib/node_modules.

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

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