{"id":10684,"date":"2021-10-05T08:03:04","date_gmt":"2021-10-05T08:03:04","guid":{"rendered":"https:\/\/linuxways.net\/?p=10684"},"modified":"2021-10-05T08:03:04","modified_gmt":"2021-10-05T08:03:04","slug":"how-to-install-and-use-nvm-on-debian-11","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/debian\/how-to-install-and-use-nvm-on-debian-11\/","title":{"rendered":"How to Install and Use NVM on Debian 11"},"content":{"rendered":"<p>There are several ways of installing Node.JS. One of them is to use the APT package manager which installs it from Debian repositories. However, this does not always install the latest version.<\/p>\n<p>Another way of installing NodeJS is using the NVM utility. NVM, short of Node Version Manager is a command-line tool used to install and manage multiple Node.JS versions. You can have multiple installations of Node.JS in a single account and decide which version to use for your project. The installation of Node.JS is user account specific and other user accounts can have their own independent installations.<\/p>\n<p>In this guide, we will walk you through the installation of NVM on Debian 11<\/p>\n<h2><strong>Step 1: Download and install the NVM utility<\/strong><\/h2>\n<p>To install NVM, you need to, first, download and run the NVM bash script as follows:<\/p>\n<pre><strong>$ curl https:\/\/raw.githubusercontent.com\/creationix\/nvm\/master\/install.sh | bash <\/strong><\/pre>\n<p>The command downloads nvm as a script to the .<strong>nvm <\/strong>folder in the home directory. It then appends the environment variables for NVM in the <strong>.bashrc <\/strong>file.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"875\" height=\"254\" class=\"wp-image-10685\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-668.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-668.png 875w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-668-300x87.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-668-768x223.png 768w\" sizes=\"auto, (max-width: 875px) 100vw, 875px\" \/><\/strong><\/p>\n<p>Next, reload the <strong>.bashrc <\/strong>file to apply the changes.<\/p>\n<pre><strong>$ source ~\/.bashrc<\/strong><\/pre>\n<p>Alternatively, simply log out and log in again and confirm the version of NVM installed.<\/p>\n<pre><strong>$ nvm --version<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"477\" height=\"105\" class=\"wp-image-10686\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-669.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-669.png 477w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-669-300x66.png 300w\" sizes=\"auto, (max-width: 477px) 100vw, 477px\" \/><\/strong><\/p>\n<h2><strong>Step 2: Install and Manage NodeJS using NVM<\/strong><\/h2>\n<p>As mentioned earlier, NVM allows developers to install multiple versions of Node.JS. To install the most recent version of NodeJS run the following command with \u2018node\u2019 as the alias for the latest version.<\/p>\n<pre><strong>$ nvm install node<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"900\" height=\"166\" class=\"wp-image-10687\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-670.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-670.png 900w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-670-300x55.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-670-768x142.png 768w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/p>\n<p>If you want to install the latest LTS (Long Term Service ) version, run the command:<\/p>\n<pre><strong>$ nvm install node --lts<\/strong><\/pre>\n<p>In our case, the latest version &#8211; v16.10.0 &#8211; is already installed.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"608\" height=\"106\" class=\"wp-image-10688\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-671.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-671.png 608w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-671-300x52.png 300w\" sizes=\"auto, (max-width: 608px) 100vw, 608px\" \/><\/p>\n<p>You can also specify a specific version of NodeJS by specifying the version number. Here, we are installing Node.JS <strong>v14.18.0.<\/strong><\/p>\n<pre><strong>$ nvm install 14.18.0<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"899\" height=\"152\" class=\"wp-image-10689\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-672.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-672.png 899w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-672-300x51.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-672-768x130.png 768w\" sizes=\"auto, (max-width: 899px) 100vw, 899px\" \/><\/p>\n<p>To list all the versions of Node.JS installed, execute:<\/p>\n<pre><strong>$ nvm ls<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"615\" height=\"275\" class=\"wp-image-10690\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-673.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-673.png 615w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-673-300x134.png 300w\" sizes=\"auto, (max-width: 615px) 100vw, 615px\" \/><\/p>\n<p>To switch to a particular Node.JS version run the command as shown. Here, we are switching to Node <strong>v16.10.0.<\/strong><\/p>\n<pre><strong>$ nvm use 16.10.0<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"550\" height=\"109\" class=\"wp-image-10691\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-674.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-674.png 550w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-674-300x59.png 300w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/p>\n<p>To verify the default version already set in your account, run:<\/p>\n<pre><strong>$ nvm run default --version<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"554\" height=\"119\" class=\"wp-image-10692\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-675.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-675.png 554w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-675-300x64.png 300w\" sizes=\"auto, (max-width: 554px) 100vw, 554px\" \/><\/p>\n<p>You can list all the available Node.JS versions which are available for download as shown.<\/p>\n<pre><strong>$ nvm ls-remote<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"146\" class=\"wp-image-10693\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-676.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-676.png 624w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-676-300x70.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/p>\n<p>Lastly, you can execute a Node.JS script with your preferred version as shown.<\/p>\n<pre><strong>$ nvm exec 14.18.0 backoffice.js<\/strong><\/pre>\n<p>Those are the basic nvm commands that you can use to install and manage multiple versions of Node.JS. We hope you found this insightful.<\/p>","protected":false},"excerpt":{"rendered":"<p>There are several ways of installing Node.JS. One of them is to use the APT package manager which installs it from Debian repositories. However, this does not always&hellip;<\/p>","protected":false},"author":1,"featured_media":10916,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[521,581],"class_list":["post-10684","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-debian","tag-debian-11","tag-nvm"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/10684","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=10684"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/10684\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/10916"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=10684"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=10684"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=10684"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}