You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/doc/applications/nodejs.md
+28-18Lines changed: 28 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,6 +60,10 @@ Be sure that:
60
60
* The folder `/node_modules` is mentioned in your `.gitignore` file
61
61
* You enable production mode by setting the [environment variable](#setting-up-environment-variables-on-clever-cloud)`NODE_ENV=production`
62
62
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
+
63
67
### Build phase
64
68
65
69
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
153
157
154
158
### Automatic detection
155
159
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:
157
161
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
161
165
162
166
To overwrite this behavior, either delete the lock file or set the `CC_NODE_BUILD_TOOL` environment variable.
163
167
164
168
## Version management
165
169
166
170
### Set Node.js version
167
171
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.
169
173
170
174
{{< runtimes_versions node >}}
171
175
172
176
> [!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.
174
178
175
179
### Bun version
176
180
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`.
180
182
181
183
### pnpm and Yarn versions
182
184
@@ -198,16 +200,24 @@ This is the default way to manage version for pnpm and Yarn when a new project i
198
200
199
201
## Development Dependencies
200
202
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.
202
217
203
-
Here are various scenarios:
218
+
## Custom run command
204
219
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.
211
221
212
222
## Use private repositories
213
223
@@ -227,7 +237,7 @@ Then, the `.npmrc` file is created automatically for your application, with the
227
237
228
238
### With CC_NPM_BASIC_AUTH
229
239
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.
0 commit comments