Managing Node.js Versions with .nvmrc
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:
Open your terminal.
Navigate to your project directory using the
cd
command.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.
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.
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