Skip to content

Commit 33893d7

Browse files
committed
aplications(nodejs): add details
1 parent 71792ad commit 33893d7

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

content/doc/applications/nodejs.md

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ Be sure that:
6060
* The folder `/node_modules` is mentioned in your `.gitignore` file
6161
* You enable production mode by setting the [environment variable](#setting-up-environment-variables-on-clever-cloud) `NODE_ENV=production`
6262

63+
### Memory management
64+
65+
`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.
66+
6367
### Build phase
6468

6569
During the build phase, Clever Cloud will install your application dependencies with the selected package manager.
@@ -153,30 +157,28 @@ Then it will be installed during deployment. You can replace `latest` with a spe
153157

154158
### Automatic detection
155159

156-
If a lock file exists in your application's main folder, the corresponding package manager is set:
160+
If a lock file exists in your application's main folder, the corresponding package manager is set. Detection priority is:
157161

158-
- If a `bun.lock` file exists, `bun` is used for build/run
159-
- If a `pnpm-lock.yaml` file exists, `pnpm` is used for build/run
160-
- If a `yarn.lock` file exists, and a 3.x/4.x version is declared in `package.json`, `yarn-berry` is used for build/run
162+
1. `yarn.lock` → if `packageManager` in `package.json` starts with `yarn@3` or `yarn@4`, `yarn-berry` is used; otherwise falls back to deprecated `yarn` (1.x)
163+
2. `pnpm-lock.yaml` `pnpm` is used for build/run
164+
3. `bun.lock` `bun` is used for build/run
161165

162166
To overwrite this behavior, either delete the lock file or set the `CC_NODE_BUILD_TOOL` environment variable.
163167

164168
## Version management
165169

166170
### Set Node.js version
167171

168-
If you need a specific version or branch of Node.js, set `CC_NODE_VERSION`. You can use major, minor, patch version, such as `24`, `23.11` or `22.15.1` for example. If this environment variable isn't set, the latest LTS version available on Clever Cloud is used.
172+
If you need a specific version or branch of Node.js, set `CC_NODE_VERSION`. You can use major, minor, patch version, such as `24`, `23.11` or `22.15.1` for example. If this environment variable isn't set and `engines.node` is not defined in `package.json`, the latest LTS version available on Clever Cloud is used.
169173

170174
{{< runtimes_versions node >}}
171175

172176
> [!NOTE]
173-
> For legacy reasons, the system prioritizes to the `engines.node` value in `package.json` over the `CC_NODE_VERSION` environment variable when both are set.
177+
> For legacy reasons, the system prioritizes the `engines.node` value in `package.json` over the `CC_NODE_VERSION` environment variable when both are set. Any `.nvmrc` file is ignored and deleted during deployment.
174178
175179
### Bun version
176180

177-
If you use Bun, your application is deployed with the latest available version on Clever Cloud:
178-
179-
{{< runtimes_versions bun >}}
181+
If you use Bun, your application is deployed with the latest available version on Clever Cloud (`{{< runtime_version bun >}}`). To customise the Bun cache directory, set `CC_BUN_INSTALL_CACHE_DIR`.
180182

181183
### pnpm and Yarn versions
182184

@@ -198,16 +200,24 @@ This is the default way to manage version for pnpm and Yarn when a new project i
198200
199201
## Development Dependencies
200202

201-
Development dependencies aren't automatically installed during the deployment. You can control their installation setting `CC_NODE_DEV_DEPENDENCIES` environment variable to `install` or `ignore`. This variable overrides the default behavior of `NODE_ENV`.
203+
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`.
204+
205+
When set to `install`, an explicit flag forces development dependencies to be included regardless of `NODE_ENV`:
206+
207+
- npm: `--production=false`
208+
- npm-ci: `--include=dev`
209+
- pnpm: `--prod false`
210+
- yarn: `--production=false`
211+
- bun: no flag (Bun includes all dependencies by default)
212+
213+
When not set or set to `ignore`, default package manager behavior applies:
214+
215+
- For Bun: development dependencies are excluded (`--omit dev` is added by default)
216+
- For npm/yarn/pnpm: depends on `NODE_ENV`. If `NODE_ENV=production`, development dependencies are excluded. Otherwise they are included.
202217

203-
Here are various scenarios:
218+
## Custom run command
204219

205-
* `CC_NODE_DEV_DEPENDENCIES=install`: Development dependencies are installed.
206-
* `CC_NODE_DEV_DEPENDENCIES=ignore`: Development dependencies aren't installed.
207-
* `NODE_ENV=production` and `CC_NODE_DEV_DEPENDENCIES=install`: Development dependencies are installed.
208-
* `NODE_ENV=production` and `CC_NODE_DEV_DEPENDENCIES=ignore`: Development dependencies aren't installed.
209-
* `NODE_ENV=production`: Package manager (npm/yarn) default behavior. Development dependencies aren't installed.
210-
* Neither `NODE_ENV` nor `CC_NODE_DEV_DEPENDENCIES` are defined: Package manager (npm/yarn) default behavior. Development dependencies are installed.
220+
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.
211221

212222
## Use private repositories
213223

@@ -227,7 +237,7 @@ Then, the `.npmrc` file is created automatically for your application, with the
227237

228238
### With CC_NPM_BASIC_AUTH
229239

230-
Or you can set `CC_NPM_BASIC_AUTH` to use basic authentication
240+
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.
231241

232242
```bash
233243
CC_NPM_BASIC_AUTH="user:password"

0 commit comments

Comments
 (0)