{"id":60205,"date":"2024-03-06T09:30:08","date_gmt":"2024-03-06T04:00:08","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=60205"},"modified":"2024-11-28T23:48:47","modified_gmt":"2024-11-28T18:18:47","slug":"node-version-using-nvmrc","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/node-version-using-nvmrc\/","title":{"rendered":"Node Version Using .nvmrc"},"content":{"rendered":"<h3>Introduction<\/h3>\n<p>When we are working with multiple <a href=\"https:\/\/www.tothenew.com\/digital-engineering\/web-development\">Node.js and React.js projects<\/a>, managing different Node versions will be very challenging. There is a tool that is simple and powerful that saves us from version-related problems which is the .nvmrc file. This tool ensures that every React.js and node.js project uses the right node version. Here we will discuss how to create and use of .nvmrc file.<\/p>\n<p><strong><em>Before going to create a .nvmrc file, Please make sure nvm should be installed in the system<\/em><\/strong><\/p>\n<h2><strong>What is nvm<\/strong><\/h2>\n<p>NVM stands for Node Version Manager it&#8217;s an open-source version manager for Node.js. With the help of the nvm tool, we manage multiple installations of Node.js on a single machine, and it allows developers to switch between different versions of Node.js.<\/p>\n<h3>How to install nvm in Ubuntu<\/h3>\n<p><strong>Step 1:-<br \/>\n<\/strong>Please make sure the system is updated by running the below command<\/p>\n<pre><em><strong>sudo apt update<\/strong><\/em><\/pre>\n<p><strong>Step 2:-<\/strong><br \/>\nDownload and install NVM using curl<\/p>\n<pre><em><strong>curl -o- https:\/\/raw.githubusercontent.com\/nvm-sh\/nvm\/v0.35.3\/install.sh | bash<\/strong><\/em><\/pre>\n<p><strong>Step 3:-<\/strong><br \/>\nHere, we will check whether NVM is installed or not<\/p>\n<pre><em><strong>nvm --version<\/strong><\/em><\/pre>\n<p><strong>Step 4:-<\/strong><br \/>\nOnce Installation of the NVM is done, we can install a specific node version.<\/p>\n<pre><strong>nvm install &lt;nodeverion&gt;<\/strong><\/pre>\n<p><strong>Step 5:-<\/strong><br \/>\nBelow the command, we can all install the node Version.<\/p>\n<p><strong>Step 6:-<\/strong><br \/>\nHere, we can switch to the Node.js version based on the requirements.<\/p>\n<pre><strong>nvm use v16.02.0<\/strong><\/pre>\n<h3>What is a .nvmrc File?<\/h3>\n<p>The <em><strong>.nvmrc<\/strong><\/em> file is a simple text file that configuration file for <strong><em>nvm<\/em><\/strong> (Node Version Manager). It&#8217;s used to install and manage the node.js versions. The <em><strong>.nvmrc<\/strong><\/em> will be available on your project\u2019s root directory. Here, we can instruct nvm to switch to the specific Node.js version required for that project<\/p>\n<h4><strong>Creating and Using .nvmrc<\/strong><\/h4>\n<p><strong>Step 1:-<\/strong><\/p>\n<p>Go to the terminal and navigate to the root directory of your project; after that, create a new file, and the name will be .nvmrc<\/p>\n<p><strong>Step 2:-<\/strong><\/p>\n<p>Open the .nvmrc; whatever node version is required in your project, you can put it here and save it. eg:- here we have node 16.20.2 require in our project<\/p>\n<p><img decoding=\"async\" src=\"\/blog\/wp-ttn-blog\/uploads\/2024\/02\/default-Node-version.png\" \/><\/p>\n<p>As you can see in the above pic, our default node version is <strong>v16.15.0,<\/strong> but the requirement is <strong>16.20.2<\/strong>. So here we will create a .<em><strong>nvmrc<\/strong><\/em> root directory of the project, and Inside the .nvmrc file, simply write <strong>16.20.2<\/strong>, After that, we will use the nvm use command.<\/p>\n<p><img decoding=\"async\" src=\"\/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-02-02-at-11.51.04-PM.png\" \/><\/p>\n<p><img decoding=\"async\" src=\"\/blog\/wp-ttn-blog\/uploads\/2024\/02\/check-node-version-install-or-not.png\" \/><\/p>\n<p>In the above image, you can see a specific node version if the node version is not available then; with the help of <em><strong>nvm install v16.20.2,<\/strong><\/em> we can install a specific node version<\/p>\n<p><img decoding=\"async\" src=\"\/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-02-02-at-11.38.57-PM.png\" \/><\/p>\n<p>You can see in the above pic, Now with the help of the <em><strong>nvm use<\/strong><\/em> command, we can switch the specific node version<\/p>\n<h3>Conclusion<\/h3>\n<p>First, you have installed the nvm and learned to manage the node version with the .nvmrc file. The .nvmrc file is an effective and powerful tool that can manage the Node.js versions. With the help of the above steps, you and your team member can use the same node.js version<\/p>\n<p>Thanks for reading! Check out our <a href=\"https:\/\/www.tothenew.com\/blog\/\">other blog posts<\/a> for more insights.<\/p>\n<div class=\"ap-custom-wrapper\"><\/div><!--ap-custom-wrapper-->","protected":false},"excerpt":{"rendered":"<p>Introduction When we are working with multiple Node.js and React.js projects, managing different Node versions will be very challenging. There is a tool that is simple and powerful that saves us from version-related problems which is the .nvmrc file. This tool ensures that every React.js and node.js project uses the right node version. Here we [&hellip;]<\/p>\n","protected":false},"author":1709,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":3277},"categories":[1439,4684,1185,3038],"tags":[1186,1124,4857],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/60205"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1709"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=60205"}],"version-history":[{"count":3,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/60205\/revisions"}],"predecessor-version":[{"id":68845,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/60205\/revisions\/68845"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=60205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=60205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=60205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}