What Is the .nvmrc File and Why You Need It for Netlify


๐ง Introduction
If you've ever deployed a Node.js or Next.js project to Netlify and hit a weird build error, there's a good chance it had something to do with your Node.js version.
That's where the .nvmrc
file comes in. It's a tiny file that solves big problems โ especially when deploying to platforms like Netlify.
๐ What Is .nvmrc
?
.nvmrc
is a config file used by Node Version Manager (NVM). It tells tools and platforms what version of Node.js your project expects.
Example:
18.18.2
That's it. One line. One version. One solution to so many problems.
๐ Why You Need It for Netlify
Netlify uses Node.js to build and run your frontend project โ and by default, it chooses a latest available version, which might break your build.
If your code was written for Node 18, but Netlify uses Node 22, boom: ๐ฅ errors like:
'next' is not recognized as a command
Unsupported Node.js version
npm ERR! missing script: export
โ
How .nvmrc
Helps
When Netlify sees a .nvmrc
file in your root directory, it automatically uses that version for the build.
Benefits:
๐ Matches your local dev environment
๐ Prevents version-based build errors
๐ Guarantees consistent deploys
๐ง How to Use .nvmrc
- Create a file in your project root:
touch .nvmrc
- Add the version you want (check Netlify-supported versions here):
18.18.2
- Commit and push it:
git add .nvmrc
git commit -m "Specify Node version for Netlify"
git push origin main
๐งช Bonus: Use It Locally Too
If you use nvm
, you can sync your local environment with the projectโs Node version by running:
nvm use
If you donโt have that version installed yet:
nvm install
๐ Final Thoughts
The .nvmrc
file might be small, but it's essential if you want reliable deployments with Netlify โ especially when working on projects with strict or legacy Node version requirements.
Next time you get a mysterious Netlify error, remember:
โIt might just be your Node version.โ
Subscribe to my newsletter
Read articles from Kelvin R. Tobias directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
