Node JS

Getting started

In Front End Hosting - Basic, one Static Site application such as Static Site Generator (SSG) is provisioned with three environments:

  • Development (Dev)

  • Staging (Stg)

  • Production (Prod) 

To view an application:

  1. Sign in to the Cloud Platform user interface.
  2. In the top menu, click Develop.
  3. Select your organization.
  4. Select an application.
  5. Click View <application name>.

    New environments are provisioned with the default content page.

  6. To verify that a site is working correctly, visit the default URL of a specific environment:

Adding content

  1. Add a public key to your Acquia profile.
  2. Clone the application’s repository.

    Code Assembly is enabled by default.

  3. Create a new branch and push your development code without node_modules.

    Code Assembly runs the install and build commands as defined in the package.json file and creates a new branch with the prefix CODE-ASSEMBLY-BUILD-, which will contain a deployable artifact.

  4. Deploy the CODE-ASSEMBLY-BUILD-<new-branch> branch.

    For more information, visit Deploying code in the same environment. After you deploy the branch, any new commits to the new branch will update the Code Assembly-generated branch and trigger its deployment.

Connecting your Git repository to Acquia platform 

  1. Add a public key to your Acquia profile.
  2. Check out a local copy of your code.
  3. Copy your code to a new Git repository.

Front End Hosting - Basic subscription details

For information about viewing your subscription details, visit Viewing subscriptions.

Monitoring a Front End Hosting - Basic site

For information about monitoring a site, visit Using Stack Metrics to monitor activity on your environments.

Configuring the package.json file

  1. In the root directory of your project, locate and open the package.json file.
  2. Edit the file to add an  extra section along with deployment configuration details because that section is a requirement for SSG applications.
    • When Code Assembly is enabled in Cloud Platform, the extra section must contain the following properties:

      {
       "extra": {       
          "acquia": {
                "code-assembly.node_version": "18",
                "code-assembly.install_command": "npm install",
                "code-assembly.build_command": "npm run build",
                "code-assembly.output_directory": "html/",
                "code-assembly.root_directory": "./"
            }
         }
      }
    • When Code Assembly is disabled in Cloud Platform, the extra section must contain the following properties:

      {
       "extra": {       
          "acquia": {
                "code-assembly.output_directory": "html/",
                "code-assembly.root_directory": "./"
            }
         }
      }

Configuration properties

Install command

  • When Code Assembly is enabled in Cloud Platform, it attempts to install dependencies by running the command defined in code-assembly.install_command. However, it runs the defined command only if the package.json file is present in the path defined in the root directory. Otherwise, it runs the npm install command by default. Code Assembly aborts the installation if the node_modules directory already exists in the branch.

    Code Assembly reads the package.json file from the root directory. If it does not find the file in the root directory, it reverts to default configuration.

  • When Code Assembly is disabled in Cloud Platform, Cloud Platform does not read code-assembly.install_command.

Build command

If the package.json file contains the code-assembly.build_command command in extra.acquia, then that command is used to build the static site.

  • The build command must be framework-specific. Code Assembly supports only npm package manager.
  • The Static Site artifact size limit for the SSG application type is 10 GB. Code Assembly does not proceed with the build if the size exceeds this limit.
  • The default build command is  npm run build. This command can be overridden by specifying the code-assembly.build_command command in the package.json file. 

Output directory

This output directory contains build outputs such as HTML, CSS, and JavaScript files, which are served for the Front End Hosting - Basic hosting. The default output directory is html/. This directory can be overridden by specifying the output directory in the package.json file.

Root directory

The main directory of your project may not always align with your application's build root. For example, a repository might have a frontend directory, which contains a stand-alone Next.js application. Therefore, you must set the root directory to ensure that the commands are executed from the correct directory of your project.

Did not find what you were looking for?

If this content did not answer your questions, try searching or contacting our support team for further assistance.

Acquia Help

Filter by product:

Node JS common questions