Node.js is a popular JavaScript runtime built on Chrome's V8 JavaScript engine. supports deploying Node.js applications quickly and easily. Using our Multi-App support you can build a micro-service oriented system mixing both Javascript and PHP applications.

Supported versions

  • 0.12
  • 4.7
  • 6.9

See for a full example with MongoDB support.


To use and Node.js together, configure the file with a few key settings, as described here (a complete example is included at the end).

  1. Specify the language of your application (available versions are listed above):

    type: "nodejs:4.4"
  2. Specify your dependencies under the nodejs key, like this:

        pm2: "^0.15.10"

    These are the global dependencies of your project (the ones you would have installed with npm install -g). Here we specify the pm2 process manager that will allow us to run the node process.

  3. Configure the command you use to start serving your application (this must be a foreground-running process) under the web section, e.g.:

        start: "PM2_HOME=/app/run pm2 start index.js --no-daemon"

    If there is a package.json file present at the root of your repository, will automatically install the dependencies. We suggest including the platformsh helper npm module, which makes it trivial to access the running environement.

    "dependencies": {
      "platformsh": "^0.0.1"
  4. Create any Read/Write mounts. The root file system is read only. You must explicitly describe writable mounts. In (3) we set the home of the process manager to /app/run so this needs to be writable.

      "/run": "shared:files/run"
  5. Include any relevant commands needed to build and setup your application in the hooks section, e.g.:

      build: |
        npm install
        npm run build
        bower install
  6. Setup the routes to your nodejs application in .platform/routes.yaml.

      type: upstream
      upstream: "node:http"
      type: upstream
      upstream: "node:http"

Here's a complete example that also serves static assets (.png from the /public directory):

name: node
type: nodejs:4.4

    start: "PM2_HOME=/app/run pm2 start index.js --no-daemon"
    #in this setup you will find your application stdout and stderr in /app/run/logs
      passthru: false
      root: "public"
      # Whether to allow files not matching a rule or not.
      allow: true
          allow: true
          expires: -1
    pm2: "^0.15.10"
  "/run": "shared:files/run"
disk: 512

In your application...

Finally, make sure your Node.js application is configured to listen over the port given by the environment (here we use the platformsh helper and get it from config.port) that is available in the environment variable PORT. Here's an example:

// Load the http module to create an http server.
var http = require('http');
// Load the configuration
var config= require("platformsh").config();

var server = http.createServer(function (request, response) {
  response.writeHead(200, {"Content-Type": "text/html"});
  response.end("<html><head><title>Hello Node.js</title></head><body><h1><img src='public/js.png'>Hello Node.js</h1><h3>Platform configuration:</h3><pre>"+JSON.stringify(config, null, 4) + "</pre></body></html>");


results matching ""

    No results matching ""