Setting the Node.js Version for Nixpacks Builds
Flightcontrol's default Nixpacks build type uses Node.js 18 by default.
This may not be the version of Node that you use for your own project, so Nixpacks supports setting the Node.js version for your builds.
The supported major versions of Node.js are 14, 16, 18, 20, and 22
When you use Nixpacks for builds, you can set the major Node version, but not the minor node version. For example, you can set the Node version to 18, but not 18.17.2.
Using the package.json File
We recommend setting the Node version in your package.json
file, so that it's clear to anyone working on your project what version of Node is required. This also works with other build and continuous integration tools.
To set the Node version in your package.json
file, add the following to the top level of your package.json
file:
{
"engines": {
"node": "18"
}
}
Nixpacks will use the major version of Node.js specified in your package.json
file.
Providing a NIXPACKS_NODE_VERSION Environment Variable
The other alternative is to tell the Nixpacks build to use a specific version of Node.js by setting the NIXPACKS_NODE_VERSION
environment variable. Set this environment variable to one of the supported major versions of Node.js (14, 16, 18, or 20).
For example, to use Node.js 20, you would set the NIXPACKS_NODE_VERSION
environment variable to 20
.
This alternative is useful if you don't want to modify your application code, but we do recommend setting the version of Node you use in your package.json
file.