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

  1. Create a file in your project root:
touch .nvmrc
  1. Add the version you want (check Netlify-supported versions here):
18.18.2
  1. 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.โ€

0
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

Kelvin R. Tobias
Kelvin R. Tobias