Node.js & Bun runtime
Overview
Clever Cloud allows you to deploy any JavaScript and TypeScript application. We do support any stable version of Node.js. Learn more about Node.js release schedule. This page explains how to set up your application to run it on our service.
Create your Node.js & Bun application
To create a new Node.js & Bun application, use the Clever Cloud Console or Clever Tools:
clever create --type nodeConfigure your Node.js & Bun application
Mandatory needs
Be sure that:
- You listen on
0.0.0.0, on the port inPORT - You have a
package.jsonfile - Your
package.jsoneither has a scripts.start or a main field - The folder
/node_modulesis mentioned in your.gitignorefile - You enable production mode by setting the environment variable
NODE_ENV=production
Memory management
NODE_OPTIONS is automatically configured with --max-old-space-size set to 3/4 of the instance’s available memory. If you already set NODE_OPTIONS with a max-old-space-size value, it is not overridden. If NODE_OPTIONS is set without max-old-space-size, the flag is appended to your existing value.
Build phase
During the build phase, Clever Cloud will install your application dependencies with the selected package manager.
About package.json
A valid package.json file should look like the following:
{
"name" : "myApp",
"version" : "0.1.0",
"main" : "myApp.js",
}or
{
"name" : "myApp",
"version" : "0.1.0",
"scripts" : {
"start" : "node myApp.js"
}
}You can use additional scripts as an alternative to Clever Cloud hooks; see the npm documentation. For example, scripts.preinstall, scripts.install and scripts.postinstall are executed during the build phase if defined. scripts.prestart and scripts.poststart are executed before and after the scripts.start command. Thus, your package.json can look like this:
{
"name" : "myApp",
"version" : "0.1.0",
"scripts" : {
"preinstall": "./download.sh", // during build phase, before dependencies installation
"postinstall": "./cleanup.sh", // during build phase, after dependencies installation
"prestart": "./prepare.sh", // during run phase, before the start command
"start" : "node myApp.js",
}
}Dependencies
If you need some modules you can easily add some with the dependencies field in your package.json. Here is an example:
| |
If your application has private dependencies, you can add a private SSH key.
Supported package managers
Clever Cloud supports any package manager compatible with Node.js ecosystem. The environment variable CC_NODE_BUILD_TOOL allows you to define which one you want to use to install dependencies during the build phase:
bun: uses Bun as a package manager and as a runtimenpmornpm-install: default, uses npm installnpm-ci: uses npm clean-installpnpm: uses pnpmyarn-berry: uses Yarncustom: use another package manager, defined withCC_CUSTOM_BUILD_TOOL
Yarn 1.x and 2.x deprecation
yarn and yarn2 are still valid values but the Yarn team no longer maintains 1.x and 2.x branches. Use yarn-berry instead.
What about Deno?
Deno is not natively supported on Clever Cloud, but you can get it using Mise, by setting a mise.toml file with the following content:
[tools]
deno = "latest"Then it will be installed during deployment. You can replace latest with a specific version.
Automatic detection
If a lock file exists in your application’s main folder, the corresponding package manager is set. Detection priority is:
yarn.lock→ ifpackageManagerinpackage.jsonstarts withyarn@3oryarn@4,yarn-berryis used; otherwise falls back to deprecatedyarn(1.x)pnpm-lock.yaml→pnpmis used for build/runbun.lock→bunis used for build/run
To overwrite this behavior, either delete the lock file or set the CC_NODE_BUILD_TOOL environment variable.
Version management
Set Node.js version
Each image includes a Node.js version installed with nvm: the latest long-term support (LTS) release when Clever Cloud built the image. Your application uses it when it doesn’t request another version.
| Default Version |
|---|
26.13.0 (npm 11.20.0) |
The end-of-life (EOL) versions are marked as such.
To request a version, set the CC_NODE_VERSION environment variable or the engines.node field in your package.json. Both accept a version or a semantic versioning range, such as 26, 24.22, 24.22.2, or >=24. A partial version is a range: 26 matches any 26.x release, 24.22 any 24.22.x release. Clever Cloud ignores and deletes any .nvmrc file during deployment.
During the build phase, Clever Cloud resolves the requested version in this order:
- If the version included in the image matches the request, your application uses it
- Otherwise, Clever Cloud installs with
nvmthe latest Node.js release that matches the request - If no release matches, the deployment fails
For example, with Node.js 26.13.0 in the image, 26 and >=24 both resolve to 26.13.0, while 24 installs the latest 24.x release. An open range such as >=24 doesn’t select the latest release: it keeps the included version as long as this version matches. The included version changes with image updates, from one patch release to the next and from one LTS branch to the next. Set a major version, such as 26, to stay on the same branch across image updates. engines.node follows the same rules, so a broad compatibility range in package.json also selects the version.
CC_NODE_VERSION takes precedence from December 1, 2026
When you set both, engines.node in package.json takes precedence over CC_NODE_VERSION, for legacy reasons. From December 1, 2026, CC_NODE_VERSION takes precedence, and engines.node only applies when this variable isn’t set. If your application sets both to different values, align them or remove CC_NODE_VERSION to keep the version engines.node selects.
Bun version
If you use Bun, your application is deployed with the latest available version on Clever Cloud (1.4.4). To customise the Bun cache directory, set CC_BUN_INSTALL_CACHE_DIR.
Bun includes a native S3 client that works with Cellar, the Clever Cloud S3-compatible object storage service, with no external dependency required.
pnpm and Yarn versions
To load a specific version, set the packageManager field in your package.json file. For example, to use pnpm@10.14.0:
{
"packageManager": "pnpm@10.14.0"
}This is the default way to manage version for pnpm and Yarn when a new project is initialized. It will define the version used for dependency installation during the build phase and in run command. Yarn 1.22.22 remains the default system version included for legacy reasons.
- If
CC_NODE_BUILD_TOOLis set toyarn-berry, the latest 4.x packaged version of Yarn becomes the system default - If you use Yarn 1.x or Yarn 2.x, a deprecation warning is displayed during deployment as they’re not maintained anymore
Tip
If you set CC_NODE_BUILD_TOOL to yarn-berry in any Clever Cloud runtime, Yarn 4.x becomes the default system version.
Development Dependencies
Development dependencies aren’t automatically installed during the deployment. You can control their installation by setting the CC_NODE_DEV_DEPENDENCIES environment variable to install or ignore.
When set to install, an explicit flag forces development dependencies to be included regardless of NODE_ENV:
- npm:
--production=false - npm-ci:
--include=dev - pnpm:
--no-prod - yarn:
--production=false - bun: no flag (Bun includes all dependencies by default)
CC_NODE_DEV_DEPENDENCIES has no effect when CC_NODE_BUILD_TOOL is set to yarn2 or yarn-berry: Clever Cloud runs yarn install with no flag and Yarn applies its own default.
When not set or set to ignore, default package manager behavior applies:
- For Bun: development dependencies are excluded (
--omit devis added by default) - For pnpm: development dependencies are excluded (
--prodis added by default) - For npm and Yarn Classic: depends on
NODE_ENV. IfNODE_ENV=production, development dependencies are excluded. Otherwise they are included.
Custom run command
To override the default start behavior (scripts.start or main field from package.json), set the CC_RUN_COMMAND environment variable. When defined, it takes priority over all other start methods.
Use private repositories
With NPM_TOKEN
Since April 2015, npm allows you to have private repositories. If you want to use such a feature, you only need to provide the auth token. Add it to your application through the NPM_TOKEN environment variable:
NPM_TOKEN="00000000-0000-0000-0000-000000000000"Then, the .npmrc file is created automatically for your application, with the registry URL and the token.
//registry.npmjs.org/:_authToken=00000000-0000-0000-0000-000000000000With CC_NPM_BASIC_AUTH
As an alternative to NPM_TOKEN, you can set CC_NPM_BASIC_AUTH to use basic authentication. The value is Base64-encoded automatically by the platform. You cannot use both NPM_TOKEN and CC_NPM_BASIC_AUTH at the same time.
CC_NPM_BASIC_AUTH="user:password"Define the host
To authenticate to another registry (like GitHub), you can use the CC_NPM_REGISTRY environment variable to define its host.
CC_NPM_REGISTRY="npm.pkg.github.com"
NPM_TOKEN="00000000-0000-0000-0000-000000000000"//npm.pkg.github.com/:_authToken=00000000-0000-0000-0000-000000000000Deployment video
Automatic HTTPS redirection
Force HTTPS, enabled by default, redirects HTTP requests to HTTPS. To do it in your application, read the load balancer headers.
If you are using Express.js, you can use express-sslify by adding:
app.use(enforce.HTTPS({
trustProtoHeader: true
}));Monitor your application with New Relic
You can use New Relic to monitor your application on Clever Cloud.
Please refer to our New Relic documentation to configure it for your application.
Troubleshooting your application
If you are often experiencing auto restart of your Node.js instance, maybe you have an application crashing that we automatically restart. To target this behavior, you can gracefully shut down with events handlers on uncaughtExeption unhandledRejection sigint and sigterm and log at this moment, so you can fix the problem.
Environment injection
Clever Cloud injects the environment variables of your application into its environment, along with those of its linked add-ons.
Custom build configurations
On Clever Cloud you can define some build configuration: like the app folder to deploy or the path to validate your application deployment is ready To do that follow the documentation here and add the environment variable you need.
To access environment variables from your code, you can use process.env.MY_VARIABLE.