Configuring Node.js

Discover our Public Cloud offer

Shared Hosting for Everyone, imagined by developers, for developers.

Discovering the Public Cloud

[package] has to be replaced by the name of the package to be installed.

Supported versions

22
20
18
16
14
12
10
8
6

The default version can be changed from the administration section, under Environment > Node.js. This is the version that is especially used when you start node.

Versions are not necessarily already installed.

Only LTS versions are made available.

Binary to use

You need to always use node (or /usr/bin/node). nodejs does not work.

To force the use of a different version of Node.js other than the default one, define the environment variable NODEJS_VERSION:

$ NODEJS_VERSION=12 node

In your scripts, use /usr/bin/node as shebang:

#!/usr/bin/node

Environment

Your Node.js environment starts off empty, with no ready installed libraries. You can use npm to install package:

$ npm install [package]

You can also use npm in global mode, the package will be installed in the $HOME/.npm-packages directory:

$ npm install -g [package]

HTTP deployment

To deploy an HTTP application with Node.js, create a Node.js type site in the Web > Sites section.

Node.js Site Type
Node.js Site Type

You need to specify the command that will start your Node.js application, for example:

node $HOME/myapp/index.js

Your application must absolutely listen to IP and the port shown in the site configuration in the Command field. The IP / HOST and PORT environment variables can also be used.