Long-term support (LTS) versions of Node.js and utilities are available. By convention, these are the even-numbered Node.js releases.
Choosing a version of Node.js
You can choose among multiple versions of Node.js:
|Node.js version||Command-line path||Sunset Date|
|14.x (default)||/opt/nodejs/v14/bin/node||April 30, 2023|
|16.x||/opt/nodejs/v16/bin/node||April 30, 2024|
If you need to switch Node.js versions, you can do so by creating or editing
.silk.ini file (for example
~/www-root/.silk.ini) and adding
the version to the
[nodejs] version = 16
Valid version choices are
default, any of the versions listed in the table
newest (which provides the newest available on the system).
From the command-line, changes will take effect when you next log in.
Web applications will need to be restarted.
Configuring web applications
Web applications use NGINX Unit as an application
server. This will automatically take care of starting up your code when
someone tries to access it with a web browser; you will not launch it directly
node. For this to work, do the following:
.silk.inifile in your site root. Add a section similar to the following.
[app] type = nodejs document-root = public startup-script = app.js cmdline-args = --arg1 --arg2=blah env.MYVAR = some value
.silk.inisection name should be either "app" or any descriptive name you wish for your application that starts with "app: ". This could be useful if you wish to configure multiple apps.
root is an optional directory under your site root containing all your application files.
document-root is the directory under your app root in which static files will be located.
startup-script is the name of the script launching your application, which should have executable permissions (
chmod u+x app.js).
cmdline-args is an optional list of command-line arguments passed to the startup script.
Any line beginning with env. will set an environment variable available within your application.
If this is the first web application in your site, a new app server will be started for your account within ten minutes.
Make the following tweaks to your application:
From inside your site root directory, run
npm link unit-http.
Since your app is launched as a script by the app server, make sure your startup script is executable (
chmod u+x app.js) and begins with a script "shebang" line pointing to your desired version of Node.js, such as
Your app will use the
unit-httpmodule instead of
httpfor receiving and responding to requests. Replace the line that requires
httpwith one for
unit-http, such as:
var http = require('unit-http');
Your app will not directly listen on a network port, so make sure your
listen()line does not referene one. You can just say something such as:
Load your application with
silk app <hostname> load. If you have multiple sites and/or multiple apps,
<hostname>is followed by the URI path of your app, such as
dev.mynetid.w3.uvm.edu/app2. If you see an error, check the app server log for details.
An application needs to be restarted for code changes to take effect. You can do this the same way you originally loaded your application:
[myusername@silk21 ~]$ silk app <hostname> load
App server logs are available at
npm are available for installing packages.
If you need to install something globally rather than inside your application's directory, you can change the default global directory to a location you own.
yarn, edit your
~/.yarnrc.yml file to include a line similar to:
npm, you can follow these directions.