Node.js

Node.js is a popular Javascript runtime that can power web applications. Opalstack provides a simple installer that creates a very basic Node.js web application.

Installation

To install a Node.js application follow our general instructions for adding applications and select "Node.js" as the application type in step 5.

When the installation is complete, the following files and directories will be present in the application directory:

  • start and stop scripts to control the operation of your application.
  • tmp: a directory containing temporary files used by your application
  • myproject: a basic Node.js "Hello World" web application
  • README: basic info regarding the new application.

Complete the setup by adding the application to a site.

Deploying your own Node.js project

To serve your own project from your installed Node.js application:

  1. Upload your project directory to the root of your application directory, for example /home/username/apps/appname. You can upload your project via SFTP or with commandline tools such as scp or rsync.

  2. Log in to a SSH session and activate the application's Node.js environment:

    cd ~/apps/appname
    source scl_source enable nodejs20
    
  3. Switch into your project directory to install your project dependencies. For example if you use npm:

    cd ~/apps/appname/projectname
    npm install
    
  4. Edit the app's start script to use the command that you use to start your app. The specific changes you make depend on your app but generally:

    • Change the PROJECT variable to the name of your project directory.
    • Change the STARTCMD variable to the full command that you use to start your app. Note that the full path to the command executable is required.