Information for: DEVELOPERS   PARTNERS

Getting started with Node.js applications and environments

If you are already familiar with the Acquia Cloud interface, getting started with a Node.js application is similar to the other applications you have already created in Acquia Cloud.

For your reference, here is how Node.js applications and environments are managed, and how you develop your code in them, which may be slightly different than your previously created applications and environments.

Managing applications

Many of the basic application management functions are the same for Acquia Cloud-hosted Drupal applications. These functions include:

  • Modifying views of applications
  • Adding applications
  • Renaming applications

For a full explanation of each of these functions, see Managing applications with the Acquia Cloud interface.

Managing environments

The Acquia Cloud implementation of Node.js uses separate environments to help you maintain a clear and orderly workflow as you develop, test, and publish your applications. An application is deployed on each of its environments, but each environment may be in a different state — possibly with a build artifact deployed. Each environment has a URL at which its application can be accessed, but only the production environment’s URL is designed to be visible to the application’s users (website visitors).

Acquia Node.js applications start with one production (Prod) environment, and one development (Dev) environments. See Resources and limitations for Node.js environments for server details.

  • Development environments - Shared between customers
  • Production environments - Dedicated to a single customer

Determining Node.js version on an environment

The Overview page for an environment displays the Node.js version installed on an environment. To check the version installed on an environment, complete the following steps:

  1. Sign in to Acquia Cloud.
  2. In the breadcrumbs menu, click the triangle and select your organization, application, and environment to display the environment’s Overview page.
  3. On the environment’s Overview page, scroll down to the Information section.

Acquia Cloud interface displays the Node.js version at the bottom of the Information section as shown in the following example:

Node.js version displayed on Overview page

Note

To request a version of Node.js for your environment other than the default, contact Acquia support.

Developing your application

Development with Node.js on Acquia Cloud requires that you create pipelines for your code.

Based on the normal pipelines workflow, after connecting your application to a repository, you must create your build definition file.

The Acquia Cloud uses the conventional npm start command to start your Node.js application. Ensure that you have a snippet similar to the following in your application’s package.json file:

"scripts": {
    "start": "node index.js"
}

Enclose your application in error-handling code that captures error information through console.log() or console.error() for log and error message display in Log Streaming.

For a detailed tutorial regarding local Drupal and Node.js setup, see Setting up a local Drupal and Node.js application.

Pipelines client commands

The pipelines client for Acquia Cloud includes commands that are specific to Node.js applications. For a full listing of all commands the pipelines client provides, see Using the Acquia Cloud pipelines client.

Example script

Here is an example script for building a pipelines artifact with your Node.js application:

version: 1.0.0
variables:
        global:
            HOSTING_API_STAGE: canary

events:
    build:
     steps:
        - build:
           script:
             - nvm install v6.11.2
             - nvm use 6.11.2
             - npm install --production
        - upload-artifact:
           script:
             - pipelines-artifact start
             - pipelines-artifact upload $SOURCE_DIR
    fail-on-build:
     steps:
        - fail:
           script:
             - pipelines-artifact fail