Logo

dev-resources.site

for different kinds of informations.

Manage Node.js version for a project using NVM and .nvmrc file

Published at
4/29/2024
Categories
development
node
nvm
Author
guidozam
Categories
3 categories in total
development
open
node
open
nvm
open
Author
8 person written this
guidozam
open
Manage Node.js version for a project using NVM and .nvmrc file

I just discovered an interesting and useful feature of NVM so I decided to let everyone know about it!

If you don’t know NVM (Node Version Manager) you can read about it in my previous post here.

NVM lets you quickly switch the Node.js version for a project to a specific one. To do so you need to create a .nvmrc file which specify the version that you want to use.

To create the file go in the solution folder and execute the command:

node -v > .nvmrc
Enter fullscreen mode Exit fullscreen mode

This command will generate the file and write something like:

v16.20.2
Enter fullscreen mode Exit fullscreen mode

Once that you have your .nvmrc file created, the next time that you will have to put your hands on the project, you will have to simply run:

nvm use
Enter fullscreen mode Exit fullscreen mode

Doing so will change your current Node.js version to the one specified in the .nvmrc file.

NB : Unfortunately NVM for Windows does not support the use command (here’s the reason), in the eventuality that you’re on Windows I still suggest to create the .nvmrc file even if you cannot change the version with the use command, in this way you can always know which version of Node.js was used for the project.

Pretty neat trick to handle your Node.js version huh?

Hope this helps!

nvm Article's
30 articles in total
Favicon
"nvm use" does not work with nvm-windows
Favicon
📦 ASDF: Gerenciando versões de linguagens e ferramentas num lugar só
Favicon
Setup NVM in your organization/admin system's like a pro
Favicon
Eligiendo la versión por defecto de node con nvm
Favicon
Migrating from nvm to mise
Favicon
OMZ: Some Plugins that I forget about
Favicon
Install/Use Any Version of Node.js with nvm (Node Version Manager)
Favicon
Brave New World: Environments
Favicon
Upgrading Node.js on Linux using NVM
Favicon
Meet phpvm: Your New PHP Best Friend Forever!
Favicon
Changing the Angular CLI version
Favicon
Como Instalar o Node.js LTS Usando o NVM
Favicon
How to install Node.js, NPM and NVM on Windows (node version manager)
Favicon
Seamlessly Manage Node.js Versions on Windows with nvm
Favicon
How to use NVM in Laravel Forge
Favicon
Understanding NPM and NVM: Essential Tools for Node.js Development
Favicon
Advanced NVM Commands for Efficient Node.js Version Management
Favicon
Why Specifying the Node.js Version is Essential
Favicon
NVM Install On Your PC
Favicon
Manage Node.js version for a project using NVM and .nvmrc file
Favicon
A simple, cross-platform, and well-tested version manager for multiple SDKs.
Favicon
Node Version Manager (nvm) overview
Favicon
NVM tips and tricks
Favicon
nvm으로 node 버전 관리하기
Favicon
HOW TO INSTALL NVM ON WINDOWS
Favicon
Installing and Managing Different Versions of Node.js with NVM
Favicon
✨ Consistency and Efficiency with .nvmrc
Favicon
NVM – Node Version Manager
Favicon
Setup Node and NVM with Fish Shell
Favicon
nvm 설치, 2024-01-24

Featured ones: