How to choose and set the Node version for your Render service
Choose the right node version for your Render app
I am a Nigerian full-stack developer. Having used Python (Django) for web development and algorithm writing for more than two years. Additionally, I use Sails.js while creating web applications. Vue.js is what I use for my front-end. I enjoy using my knowledge to improve and simplify situations, and I am eager to learn new things. I'm on a mission to develop my competence.
Recently, I worked on a project using Astro. Once the project was up and running, I chose to connect the repo to Render so I could publicly view and share my progress.
I hosted a VueJS static site on Render, ihwiki - a collaborative knowledge base for indie hackers, and it all worked great with little or no issue. I expected the process to go smoothly with Astro, but it did not. After countless trials and errors, I decided to read the error log to trace the issue. I discovered that the Render's default node version does not support Astro.
This article will show you the different ways you can set the version of node you want to use for your web application on Render if you do not want to use the default.
The possible ways are:
Set NODE_VERSION as an environmental variable.
Create a
.node-versionfile in your root directory.Create a
.nvmrcfile in your root directory.Specify
engineinpackage.json.
Let's get started.
Set NODE_VERSION as an environmental variable
By default, Render uses 14.17.0.
Create an environmental variable NODE_VERSION in the project you want to use, then input the value of the node version you want to work with.

Create a .node-version file in your root directory
In the root directory of your project, create a file called .node-version with no file extension attached.
Type the same node version you want to work with as specified in the environmental variable.
18.18.0
Create a .nvmrc file in your root directory
Once that is done, create a .nvmrc file in your root directory, just like the previous file.
It is also in the same format; type the specific version you want.
Specify engine in package.json
Open your package.json file then add engines property to specify the node version you want to work with.
"engines": {
"node": ">=18.18.0 <19.0.0"
}
Render uses any package.json file found in the subdirectories if it is not available in the root directory.
Wrap!
You can follow any of those ways to set the node version you want for your Render service.
One bonus thing you can do is set your build command to npm install && npm run build, just to make sure the packages are installed before building.
See you at the next one! 🤝
