{"id":1362,"date":"2023-05-29T11:36:46","date_gmt":"2023-05-29T11:36:46","guid":{"rendered":"http:\/\/kabiliravi.com\/?page_id=1362"},"modified":"2023-05-29T11:36:46","modified_gmt":"2023-05-29T11:36:46","slug":"install-node-js-on-linux-unix","status":"publish","type":"page","link":"http:\/\/kabiliravi.com\/index.php\/software\/programming\/my-javascript-tutorial\/install-nodejs-using-nvm\/install-node-js-on-linux-unix\/","title":{"rendered":"Install Node.js on Linux\/Unix"},"content":{"rendered":"\n<p>I encourage install <strong>Node.js<\/strong> using <strong>Node Version Manager (nvm)<\/strong> tool, so that you can switch easily between different versions of Node.js, specially when you are working with different projects that are tied to different versions of Node.js.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Install nvm<\/h1>\n\n\n\n<p>On Linux machines first, you need to run the nvm installer script. The nvm installer script creates an environment entry to the login script of the current user. You can either log out and log in again to load the environment or execute the below command to do the same. <\/p>\n\n\n\n<pre class=\"wp-block-code\">\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">$ curl https:\/\/raw.githubusercontent.com\/creationix\/nvm\/master\/install.sh | bash<\/div><\/div>\n\n<\/pre>\n\n\n\n<p>The nvm installer script creates an environment entry to the login script of the current user. You can either log out and log in again to load the environment or execute the below command to do the same:<\/p>\n\n\n\n<pre class=\"wp-block-code\">\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">$ source ~\/.bashrc &nbsp;(or ~\/.zshrc)<\/div><\/div>\n\n<\/pre>\n\n\n\n<p>And based on your shell terminal manager you need to put the following lines in their startup profile files:<\/p>\n\n\n\n<pre class=\"wp-block-code\">\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">export NVM_DIR=&quot;$HOME\/.nvm&quot;<br \/>\n&amp;#91; -s &quot;$NVM_DIR\/nvm.sh&quot; ] &amp;amp;&amp;amp; \\. &quot;$NVM_DIR\/nvm.sh&quot; &nbsp;# This loads nvm<br \/>\n&amp;#91; -s &quot;$NVM_DIR\/bash_completion&quot; ] &amp;amp;&amp;amp; \\. &quot;$NVM_DIR\/bash_completion&quot; &nbsp;# This loads nvm bash_completion<\/div><\/div>\n\n<\/pre>\n\n\n\n<p>For <strong>Zsh<\/strong> you will put the above lines in the <strong>~\/.zshrc<\/strong> file and for <strong>bash<\/strong> in <strong>~\/.bashrc<\/strong><\/p>\n\n\n\n<p>You can run the following checking nvm version command to see if <strong>nvm<\/strong> has been installed or not<\/p>\n\n\n\n<pre class=\"wp-block-code\">\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">nvm --version<\/div><\/div>\n\n<\/pre>\n\n\n\n<p>In the &#8220;Please note &#8230;&#8221; phrase please notice that you need to create a folder called <strong>.nvm<\/strong> in your home directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\">\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">$ &nbsp;mkdir ~\/.nvm<\/div><\/div>\n\n<\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">Install Node.js<\/h1>\n\n\n\n<p>Now to install <strong>node.js version 10.16.3<\/strong> for example, you can use the <strong>nvm<\/strong> command like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\">\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">$ nvm install 19.8.1<\/div><\/div>\n\n<\/pre>\n\n\n\n<p>You should be able to see a log like this, you it is successfully installed:<\/p>\n\n\n\n<pre class=\"wp-block-code\">\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">Downloading and installing node v19.8.1...<br \/>\nDownloading https:\/\/nodejs.org\/dist\/v19.8.1\/node-v19.8.1-linux-x64.tar.xz...<br \/>\n############################################################################################################################################################ 100.0%<br \/>\nComputing checksum with sha256sum<br \/>\nChecksums matched!<br \/>\nNow using node v19.8.1 (npm v9.5.1)<br \/>\nCreating default alias: default -&gt; 19.8.1 (-&gt; v19.8.1)<\/div><\/div>\n\n<\/pre>\n\n\n\n<p>As you see in the last line the default alias will be assigned to your first node.js installation<\/p>\n\n\n\n<p>Using node &#8211;version, you can check your installed node version:<\/p>\n\n\n\n<pre class=\"wp-block-code\">\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">$ node --version<br \/>\nv19.8.1<\/div><\/div>\n\n<\/pre>\n\n\n\n<p>As the part of node.js installation the <strong>Node Package Manager (npm) <\/strong>command tool also will be installed. You can check npm command line tool version using &#8211;version switch as well:<\/p>\n\n\n\n<pre class=\"wp-block-code\">\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">$ npm --version<br \/>\n9.5.1<\/div><\/div>\n\n<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I encourage install Node.js using Node Version Manager (nvm) tool, so that you can switch easily between different versions of Node.js, specially when you are working with different projects that are tied to different versions of Node.js. Install nvm On Linux machines first, you need to run the nvm installer script. The nvm installer script [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1097,"menu_order":1,"comment_status":"closed","ping_status":"closed","template":"","meta":{"ngg_post_thumbnail":0,"footnotes":""},"class_list":["post-1362","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/pages\/1362","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/comments?post=1362"}],"version-history":[{"count":1,"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/pages\/1362\/revisions"}],"predecessor-version":[{"id":1363,"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/pages\/1362\/revisions\/1363"}],"up":[{"embeddable":true,"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/pages\/1097"}],"wp:attachment":[{"href":"http:\/\/kabiliravi.com\/index.php\/wp-json\/wp\/v2\/media?parent=1362"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}