Setting the Node.js Version for Nixpacks Builds
This documentation is for when you are using Flightcontrol’s Nixpacks build type.
Nixpacks 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 Node versions supported by Nixpacks depend on the version of Nixpacks.
Nixpacks v1.39.0 supports Node.js 16, 18 (default), 20, 22, and 23
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.
If you have an older Nixpacks version, you can upgrade Nixpacks by following these upgrade instructions.
Change the Node Version With One of the Following
Set the NIXPACKS_NODE_VERSION
environment variable
Specify the Node.js version by setting the NIXPACKS_NODE_VERSION
environment variable to one of the supported major versions of Node.js.
For example, to use Node.js 20, you would set the NIXPACKS_NODE_VERSION
environment variable to 20
.
Specify the engines.node field in package.json
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"
}
}
Create a .nvmrc file in your project and specify the version or alias (lts/*)
Only a major version can be specified. For example, 18.x or 20.
Nixpacks Node Documentation
For more details, see the Nixpacks Node Documentation.
Troubleshooting
If you have an issue with changing the node version on EC2 builders, try refreshing the builder by clicking Refresh builder in the service’s Danger Zone. This will clear all the cache and automatically provision a new builder.