Managing Node.js Versions with .nvmrc

N Praveen KumarN Praveen Kumar
1 min read

Setting up a .nvmrc file ensures consistency in Node.js versions across your project team, minimizing version-related issues and maintaining uniform development environments. The .nvmrc file informs Node Version Manager (NVM) which Node.js version to use within your project.

Follow these steps to set up a .nvmrc file:

  1. Open your terminal.

  2. Navigate to your project directory using the cd command.

  3. Once in your project directory, create a .nvmrc file by running one of the following commands:

     echo "14.17.3" > .nvmrc
     # or
     node -v > .nvmrc
    

    Replace "14.17.3" with your desired Node.js version.

  4. After creating the file, verify its contents using the cat command:

     cat .nvmrc
    

    This should display the version you specified in step 3.

Remember, each time you navigate to your project directory, ensure you're using the correct Node.js version by running:

nvm use

Alternatively, automate this process by adding the nvm use command to your bash/zsh profile, ensuring the correct Node.js version is used every time you open a new terminal window.

10
Subscribe to my newsletter

Read articles from N Praveen Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

N Praveen Kumar
N Praveen Kumar