Node.js

From DreamFactory
Jump to: navigation, search

Info

We support writing event scripts and custom scripting service scripts running under Node.js. DreamFactory will call node directly to run the script.

Modules

Bitnami installs-Linux and Bitnami VM

This tutorial covers installing Node.js in Linux environments and on the Bitnami VM which uses Ubuntu Linux. There are several ways to install Node.js, for this tutorial we are going to use the wget utility to download the Node tarball (compressed and archived file source) to ensure we get the most recent version of Node.js.

Linux -- Bitnami VMs

In this tutorial we will be installing Node.js version 4.4.0. For a list of other available versions visit the Node website here .
Note: The tutorial is still applicable when installing different versions of Node. You'll only need to adjust the versioning information in the commands to correspond with the version you wish to install. As a general rule it is recommended to install the stable version.

Bitnami VM

Note: Some commands may require elevated privileges to run. If you aren't successful or the initial command displays an error try running the command using sudo.

  • Change directories to where you wish to install Node.js. We recommend using /usr/local/bin as it is the default path in the .env file we will be editing to enable Node.js for use within Dreamfactory:
    • $ cd /usr/local/bin
  • From this directory we will use the wget utility to download the Node.js tarball:
    • $ wget https://nodejs.org/dist/v4.4.0/node-v4.4.0.tar.gz
  • Unzip the tarball:
    • $ tar -zxf node-v4.4.0.tar.gz
  • Change directories into the directory where you unzipped the contents of the file:
    • $ cd node-v4.4.0

The next few steps will compile and build the installation

  • Configure Node.js:
    • $ ./configure
  • Make the file:
    • $ make
  • Install the file:

Note: Use sudo to install Node.js globally

  • $ sudo make install
  • After successfully installing Node.js you will be able to use Node.js for scripting and NPM to install additional modules.
  • Edit the .env file uncommenting the DF_NODEJS_PATH by removing the two hash signs (##) preceding the path.

Note: By default the path is /usr/local/bin. If you installed elsewhere in another directory now is the time to specify the relevant path.

  • Save your changes and restart Apache.

Linux

Note: Some commands may require elevated privileges to run. If you aren't successful or the initial command displays an error try running the command using sudo.

  • It is recommended to bring your Linux distro up to date prior to installing Node.js to ensure the libraries required to install Node.js are current. Issue the following commands:
    • $ sudo apt-get update
    • $ sudo apt-get upgrade
    • $ sudo apt-get install build-essential openssl libssl-dev pkg-config

Note: Python should be installed. In the event it is not you will need to install Python before proceeding with the installation. Python versions and installation options can be found here

  • Change directories to where you wish to install Node.js. We recommend using /usr/local/bin as it is the default path in the .env file we will be editing to enable Node.js for use within Dreamfactory:
    • $ cd /usr/local/bin
  • From this directory we will use the wget utility to download the Node.js tarball:
    • $ wget https://nodejs.org/dist/v4.4.3/node-v4.4.3.tar.gz
  • Unzip the tarball:
    • $ tar -zxf node-v4.4.3.tar.gz
  • Change directories into the directory where you unzipped the contents of the file:
    • $ cd node-v4.4.3

The next few steps will compile and build the installation

  • Configure Node.js:
    • $ ./configure
  • Make the file:
    • $ make
  • Install the file:

Note: Use sudo to install Node.js globally

  • $ sudo make install
  • After successfully installing Node.js you will be able to use Node.js for scripting and NPM to install additional modules.
  • Edit the .env file uncommenting the DF_NODEJS_PATH by removing the two hash signs (##) preceding the path.

Note: By default the path is /usr/local/bin. If you installed elsewhere in another directory now is the time to specify the relevant path.

  • Save your changes and restart Apache.