Our announcement about supporting new languages generated enthusiasm, and several customers are already running Node.js applications. We’re therefore keeping our momentum up in this post, which focuses, as you might expect, on Node.js.

A major language

As promised last week, we have a surprise: Node.js is becoming the fourth major language that alwaysdata will be supporting, after PHP, Python, and Ruby. What does this mean?

In a certain way, you could say that alwaysdata has supported Node.js forever: “all” you had to do was to download the interpreter from the official website into your account to make Node.js run. On the web side, though, you had to play it clever in order to run the application, for example by using PHP in reverse proxy. Doable… but complicated.

That it’s becoming a major language implies:

  • that we’ve pre–installed the interpreter, and that it is even possible to choose from among several versions of the interpreter (via the Environment menu in alwaysdata’s administration). Today, Node.js is available in versions 6.x (6.11.2) and 8.x (8.4.0)
  • that new versions of the interpreter will be regularly installed, not just security updates
  • that it will be easy to launch a web application in this language
  • that it will be easy to install external dependencies, by using the official package manager in SSH. For Node.js, that’s npm, which is also pre-installed

We’ve thus added a new type of website, Node.js. It’s similar to the User program type – since Node.js applications integrate their own HTTP server and don’t require an intermediary layer – with one main difference: it’s possible to specify an explicit version of Node.js for this site. And therefore to have several distinct websites using different versions of Node.js.

Example: deploying an Express application

Express is one of the best-known Node.js frameworks. Let’s see how to host an application developed using it.

  • First off, we have to install Express. Follow the official documentation, executing the commands in SSH (and accepting everything by default):

  • Then, let’s create the app.js file, all the while continuing to follow Express’s documentation. Modify the code slightly so that the application is listening on the IP and port that will be provided as environment variables:

  • Finally, from within alwaysdata’s administration, let’s create a Node.js type site, inserting the following command:

There you have it: our little Express application can indeed be reached!

Next language coming up, for the second post in our series: Lua.