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
andstop
scripts to control the operation of your application.tmp
: a directory containing temporary files used by your applicationmyproject
: a basic Node.js "Hello World" web applicationREADME
: 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:
-
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 asscp
orrsync
. -
Log in to a SSH session and activate the application's Node.js environment:
cd ~/apps/appname source scl_source enable nodejs20
-
Switch into your project directory to install your project dependencies. For example if you use
npm
:cd ~/apps/appname/projectname npm install
-
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.
- Change the