Configure the build base for an Express app

When using the expressjs-framework extension, there are different cases for customising the Ubuntu base and the Node.js version to be included. The main differences between the cases are:

  • Whether to use the bare base or an Ubuntu base.

  • Whether Node.js is installed from Ubuntu package archive or the npm plugin.

The remainder of this page discusses the combinations of Ubuntu bases and sources for Node.js. Support for Ubuntu 26.04 LTS is experimental.

Note

Part names added by the extension vary by Ubuntu version. On Ubuntu 24.04 LTS, write extension/part; on Ubuntu 26.04 LTS and higher, write extension.part. For rocks with base: bare, follow the convention for the configured build-base.

Ubuntu base, Node.js from Ubuntu package archive

rockcraft.yaml
base: ubuntu@24.04
extensions:
    - expressjs-framework
rockcraft.yaml
base: ubuntu@26.04
extensions:
    - expressjs-framework

In this case, the npm plugin copies the app’s files and installs its dependencies. Node.js then provides a runtime and launches the app. The npm and Node.js versions are determined by the versions shipped with the Ubuntu base. Search the Ubuntu package archive for the npm and Node.js versions available in the selected Ubuntu release.

Ubuntu base, Node.js from npm plugin

rockcraft.yaml
base: ubuntu@24.04
extensions:
    - expressjs-framework
parts:
    expressjs-framework/install-app:
        npm-include-node: true
        npm-node-version: 20.12
rockcraft.yaml
base: ubuntu@26.04
extensions:
    - expressjs-framework
parts:
    expressjs-framework.install-app:
        npm-include-node: true
        npm-node-version: 20.12

In this case, the npm plugin copies the app’s files and installs its dependencies. Node.js and npm are installed by the npm plugin.

Bare base, Node.js from Ubuntu package archive

rockcraft.yaml
base: bare
build-base: ubuntu@24.04
extensions:
    - expressjs-framework
rockcraft.yaml
base: bare
build-base: ubuntu@26.04
extensions:
    - expressjs-framework

In this case, the npm plugin copies the app’s files and installs its dependencies. Node.js then provides a runtime and launches the app. The npm and Node.js versions are determined by the versions shipped with the Ubuntu build base.

Bare base, Node.js from npm plugin

rockcraft.yaml
base: bare
build-base: ubuntu@24.04
extensions:
    - expressjs-framework
parts:
    expressjs-framework/install-app:
        npm-include-node: true
        npm-node-version: 20.12
rockcraft.yaml
base: bare
build-base: ubuntu@26.04
extensions:
    - expressjs-framework
parts:
    expressjs-framework.install-app:
        npm-include-node: true
        npm-node-version: 20.12

In this case, the npm plugin copies the app’s files and installs its dependencies. Node.js and npm are installed by the npm plugin. For different possible values for the npm-node-version key, refer to npm plugin documentation.