Upsun User Documentation

JavaScript/Node.js

Try Upsun for 15 days
After that, enjoy the same, game-changing Upsun features for less with the First Project Incentive!ยน A monthly $19 perk!
ยนTerms and conditions apply
Activate your 15-day trial

When dealing with Javascript/Node.js stacks, the information below may help customize your configuration. These sections provide Javascript/Node.js-specific configuration details, but you can also refer to the common Upsun documentation:

Build flavors Anchor to this heading

By default, Upsun makes assumptions about how you want to build your application. Namely, that you are managing your dependencies with npm, and that the very first thing you’d like to run is a particular and common production flavor of npm install.

This is called a build flavor, but its assumption may prove inappropriate for your application and cause your builds to fail (such as if you’d like to use yarn or bun instead of npm). Therefore, you can disable this feature.

Available package managers Anchor to this heading

Certain package managers come pre-installed on all Upsun nodejs container types:

  • npm; example: npm install platformsh-config
  • npx; example: npx create-strapi-app <APP_NAME>
  • bun; example: bun install platformsh-config

You can also use Yarn if you install it explicitly, or nvm.

Sample configuration Anchor to this heading

Below are some examples from common Node.js framework configuration:

.upsun/config.yaml
applications:
  app:
    source:
      root: "/"
    type: "nodejs:20"
    web:
      commands:
        start: "npx next start -p $PORT"
    build:
      flavor: none
    dependencies:
      nodejs:
        sharp: "*"
#services:
#  db:
#    type: postgresql:15
routes:
  "https://{default}/":
    type: upstream
    upstream: "app:http"
  # A basic redirect definition
  # More information: https://docs.upsun.com/define-routes.html#basic-redirect-definition
  "https://www.{default}/":
    type: redirect
    to: "https://{default}/"
.upsun/config.yaml
applications:
  app:
    source:
      root: "/"
    type: "nodejs:20"
    web:
      commands:
        start: "node index.js"
    build:
      flavor: none
    dependencies:
      nodejs:
        sharp: "*"
#services:
#  db:
#    type: postgresql:14
routes:
  "https://{default}/":
    type: upstream
    upstream: "app:http"
  # A basic redirect definition
  # More information: https://docs.upsun.com/define-routes.html#basic-redirect-definition
  "https://www.{default}/":
    type: redirect
    to: "https://{default}/"
.upsun/config.yaml
applications:
  app:
    source:
      root: "/"
    type: "nodejs:20"
    relationships:
      postgresql: "postgresql:postgresql"
    mounts:
      ...
    web:
      commands:
        start: "NODE_ENV=production yarn start"
    build:
      flavor: none
    dependencies:
      nodejs:
        yarn: "^1.22.0"
    hooks:
      build: |
        set -eux
        yarn
        yarn build        
services:
  postgresql:
    type: postgresql:15

routes:
  "https://{default}/":
    type: upstream
    upstream: "app:http"
  # A basic redirect definition
  # More information: https://docs.upsun.com/define-routes.html#basic-redirect-definition
  "https://www.{default}/":
    type: redirect
    to: "https://{default}/"

Frameworks Anchor to this heading

The Upsun documentation includes a wide array of community resources to help with framework-specific configuration:

Get support Anchor to this heading

While there are virtually no restrictions to you deploying any kind of application on Upsun, configuration may still be unclear at this point.

Not to worry! The Upsun community is here to help. Come and say hello, share your work, ask for help, and peek in on what others are working on.

Welcome to the Upsun community!

Is this page helpful?