|
| 1 | +--- |
| 2 | +pcx_content_type: concept |
| 3 | +title: Build image |
| 4 | +rss: https://github.com/cloudflare/cloudflare-docs/commits/production/content/pages/_partials/_platform-language-support-and-tools.atom |
| 5 | +--- |
| 6 | + |
| 7 | +import { |
| 8 | + PagesBuildEnvironment, |
| 9 | + PagesBuildEnvironmentLanguages, |
| 10 | + PagesBuildEnvironmentTools, |
| 11 | +} from "~/components"; |
| 12 | + |
| 13 | +Cloudflare Pages' build environment has broad support for a variety of languages, such as Ruby, Node.js, Python, PHP, and Go. |
| 14 | + |
| 15 | +If you need to use a [specific version](/pages/configuration/build-image/#overriding-default-versions) of a language, (for example, Node.js or Ruby) you can specify it by providing an associated environment variable in your build configuration, or setting the relevant file in your source code. |
| 16 | + |
| 17 | +## Supported languages and tools |
| 18 | + |
| 19 | +In the following tables, review the preinstalled versions for languages and tools included in the Cloudflare Pages' build image, and the environment variables and/or files available for [overriding the preinstalled version](/pages/configuration/build-image/#overriding-default-versions): |
| 20 | + |
| 21 | +### Languages and runtime |
| 22 | + |
| 23 | +<PagesBuildEnvironmentLanguages /> |
| 24 | + |
| 25 | +:::note[Any version] |
| 26 | +Under Supported versions, "Any version" refers to support for all versions of the language or tool including versions newer than the Default version. |
| 27 | +::: |
| 28 | + |
| 29 | +### Tools |
| 30 | + |
| 31 | +<PagesBuildEnvironmentTools /> |
| 32 | + |
| 33 | +:::note[Any version] |
| 34 | +Under Supported versions, "Any version" refers to support for all versions of the language or tool including versions newer than the Default version. |
| 35 | +::: |
| 36 | + |
| 37 | +### Frameworks |
| 38 | + |
| 39 | +To use a specific version of a framework, specify it in the project's package manager configuration file. |
| 40 | +For example, if you use Gatsby, your `package.json` should include the following: |
| 41 | + |
| 42 | +``` |
| 43 | +"dependencies": { |
| 44 | + "gatsby": "^5.13.7", |
| 45 | +} |
| 46 | +``` |
| 47 | + |
| 48 | +When your build starts, if not already [cached](/pages/configuration/build-caching/), version 5.13.7 of Gatsby will be installed using `npm install`. |
| 49 | + |
| 50 | +## Overriding default versions |
| 51 | + |
| 52 | +To override default versions of languages and tools in the build system, you can either set the desired version through environment variables or by adding files to your project. |
| 53 | + |
| 54 | +To set the version using **environment variables**, you can: |
| 55 | + |
| 56 | +1. Find the environment variable name for the language or tool in [this table](/pages/configuration/build-image/#supported-languages-and-tools). |
| 57 | +2. Add the environment variable on the dashboard by going to **Settings** > **Environmnet variables** in your Pages project, or [add the environment variable via Wrangler](/workers/configuration/environment-variables/#add-environment-variables-via-wrangler). |
| 58 | + |
| 59 | +Or, to set the version by **adding a file** to your project, you can: |
| 60 | + |
| 61 | +1. Find the environment variable name for the language or tool in [this table](/pages/configuration/build-image/#supported-languages-and-tools). |
| 62 | +2. Add the specified file name to the root directory of your project, and add the desired version number as the contents of the file. |
| 63 | + |
| 64 | +For example, if you were previously relying on the default version of Node.js in the v1 build system, to migrate to v2, you must specify that you need Node.js `12.18.0` by setting a `NODE_VERSION = 12.18.0` environment variable or by adding a `.node-version` or `.nvmrc` file to your project with `12.18.0` added as the contents to the file. |
| 65 | + |
| 66 | +## V2 build system |
| 67 | + |
| 68 | +The [v2 build system](https://blog.cloudflare.com/moderizing-cloudflare-pages-builds-toolbox/) announced in May 2023 brings several improvements to project builds. |
| 69 | + |
| 70 | +### V1 to V2 Migration |
| 71 | + |
| 72 | +To migrate to this new version, configure your Pages project settings in the dashboard: |
| 73 | + |
| 74 | +1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com) and select your account. |
| 75 | +2. Select **Workers & Pages** > in **Overview**, select your Pages project. |
| 76 | +3. Go to **Settings** > **Build & deployments** > **Build system version** and select the latest version. |
| 77 | + |
| 78 | +If you were previously relying on the default versions of any languages or tools in the build system, your build may fail when migrating to v2. To fix this, you must specify the version you wish to use by [overriding](/pages/configuration/build-image/#overriding-default-versions) the default versions. |
| 79 | + |
| 80 | +### Limitations |
| 81 | + |
| 82 | +Here are some limitations with the v2 build system: |
| 83 | + |
| 84 | +- Specifying Node.js versions as codenames (for example, `hydrogen` or `lts/hydrogen`). |
| 85 | +- Detecting Yarn version from `yarn.lock` file version. |
| 86 | +- Detecting pnpm version detection based `pnpm-lock.yaml` file version. |
| 87 | +- Detecting Node.js and package managers from `package.json` -> `"engines"`. |
| 88 | +- `pipenv` and `Pipfile` support. |
| 89 | + |
| 90 | +## Build environment |
| 91 | + |
| 92 | +Cloudflare Pages builds are run in a [gVisor](https://gvisor.dev/docs/) container. |
| 93 | + |
| 94 | +<PagesBuildEnvironment /> |
0 commit comments