How to use node version manager (nvm for windows) to handle different node-versions
Tags: nvm, node, cli, tooling
Published: 2021-06-16 09:36:16

*Disclaimer: This is about nvm for windows. If you are on [mac/linux follow this link to find the correct version](https://github.com/nvm-sh/nvm).*

<!-- wp:paragraph -->
<p>Have you ever experienced difficulties with a project because you are on the wrong node version? I have! A lot of projects break, or won't build,  if you don't have the required version. Previously I used to uninstall/install the correct version manually. And it was a pain everytime. And what if you are working on multiple projects that all uses different node versions? This is where NVM comes in handy.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>With nvm you can have multiple versions of node installed at the same time, and easily switch between them! In this blogpost I will show you how to install and use nvm.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Installing nvm for windows</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Go to <a href="https://github.com/coreybutler/nvm-windows/releases" target="_blank" rel="noreferrer noopener" title="https://github.com/coreybutler/nvm-windows/releases">nvm-windows github repo and download the zip-file</a> containing the installation wizard.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Run the installation wizard, click next a bunch of times, and then wait while it installes on your computer. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>When its finished open your CLI (command line interface). I use windows terminal, but regular command prompt (or any other) will do to. If nvm installed correctly you can now run nvm version and get the version number in return. </p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>nvm version</code></pre>
<!-- /wp:code -->

<!-- wp:heading -->
<h2>Using nvm</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p><strong>Install versions of node</strong><br>Now you can start installing different node versions. You do this by running nvm install and the version number you would like to install. So if you want to install node version 10.23.2, you would run the following command</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>nvm install 10.23.2</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p><strong>See the versions you have installed</strong><br>To see what versions you have already installed simply run <code><strong>nvm list</strong></code></p>
<!-- /wp:paragraph -->

![The image shows how to use nvm for windows to list all installed node versions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rpf07k326odso4548qlo.png)

In the above picture you can see that I have installed seven different versions of node, and I'm currently using 10.23.2.

**Switch between versions**
To switch version run nvm use followed by the version number
<!-- wp:code -->
<pre class="wp-block-code"><code>nvm use 12.21.0</code></pre>
<!-- /wp:code -->

And thats it! You can now switch between different versions.

## Worth noticing
Its [written so well in the documentation](https://github.com/coreybutler/nvm-windows) so I will simply quote it here:

> Please note that any global npm modules you may have installed are not shared between the various versions of node.js you have installed. Additionally, some npm modules may not be supported in the version of node you're using, so be aware of your environment as you work.

***
<!-- wp:paragraph -->
<p>Did you find this article usefull?&nbsp;<a href="https://twitter.com/acupof_dev" target="_blank" rel="noreferrer noopener">Follow me on twitter</a>&nbsp;to be notified when I publish something new!</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Also, if you have any feedback or questions, please let me know in the comments below.&nbsp;:) </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Thank you for reading, and happy coding!</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>/Eli</p>
<!-- /wp:paragraph -->