{"id":8912,"date":"2021-07-01T21:50:53","date_gmt":"2021-07-01T16:20:53","guid":{"rendered":"https:\/\/codeforgeek.com\/?p=8912"},"modified":"2023-02-09T15:22:23","modified_gmt":"2023-02-09T09:52:23","slug":"update-nodejs-version-windows-linux-macos","status":"publish","type":"post","link":"https:\/\/codeforgeek.com\/update-nodejs-version-windows-linux-macos\/","title":{"rendered":"How to Update Node Version on Windows, Linux, and macOS"},"content":{"rendered":"\n<p>Node.js is an extremely vast, server-side open-source JavaScript environment that runs on Chrome\u2019s V8 JS engine. This enormousness of Node.js has resulted in a huge and active community of users, flooding contributions every second.<\/p>\n\n\n\n<p>Node.js is an emerging technology and it provides regular updates, it is essential to keep updating to the latest versions of Node to follow up with the community and upcoming documentation.<\/p>\n\n\n\n<p>The new versions come with more enhanced security, introducing better features considering the increasing threats and changing demands out there.<\/p>\n\n\n\n<p>In this tutorial, we will walk you through various ways of updating Node.js on MacOS, Windows and Linux.<\/p>\n\n\n\n<p><strong><em>Also Read: <a href=\"https:\/\/codeforgeek.com\/how-to-create-nodejs-npm-package\/\" data-type=\"URL\" data-id=\"https:\/\/codeforgeek.com\/how-to-create-nodejs-npm-package\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Build and Publish a NPM Package<\/a><\/em><\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Check the version of Node.js<\/h2>\n\n\n\n<p>Before we begin, let\u2019s start by checking our version of Node.js, like this:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nnode \u2013version\n<\/pre><\/div>\n\n\n<p>or<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nnode -v\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">Different Ways to Update Node on macOS<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. <strong>npm<\/strong><\/h3>\n\n\n\n<p><a href=\"https:\/\/codeforgeek.com\/nodejs-npm-node-package-manager\/\" data-type=\"URL\" data-id=\"https:\/\/codeforgeek.com\/nodejs-npm-node-package-manager\/\">NPM<\/a>(node package manager) is an online open-source repository for publishing Node.js projects. It is also a command-line utility for interacting with those repositories and helps in package installations.<\/p>\n\n\n\n<p>If you are a MacOS user, this simple update method of using <strong>npm<\/strong> for Node.js update is relevant for you.<\/p>\n\n\n\n<p>To update Node.js via the command line, we can use a tool called <strong>n <\/strong>in the npm command. This will help us interact with different versions of Node.<\/p>\n\n\n\n<p><strong>Let us first clear any cache that\u2019s present:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nnpm cache clean \u2013f\n<\/pre><\/div>\n\n\n<p><strong>Installing n globally:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nnpm install -g n\n<\/pre><\/div>\n\n\n<p><strong>Now that we have n installed, let\u2019s install the latest stable version of Node:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo n stable\n<\/pre><\/div>\n\n\n<p><strong>You may even choose to install the latest features by:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo n latest\n<\/pre><\/div>\n\n\n<p><strong>To download a specific version, you can simply do this:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nn 14.17.1\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">2. Homebrew<\/h3>\n\n\n\n<p>Homebrew is made for MacOS and is a popular package management tool. We can use it to update the version of Node.js on our Mac machine.<\/p>\n\n\n\n<p><strong>Start by running this command in our MacOS terminal:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nbrew install node\n<\/pre><\/div>\n\n\n<p><strong>Update Homebrew before updating Node, run:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nbrew update\n<\/pre><\/div>\n\n\n<p><strong>Update node:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nbrew upgrade node\n<\/pre><\/div>\n\n\n<p><strong>To easily switch between Node.js versions:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nbrew switch node 14.17.1\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">How to Update NodeJS on Windows<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>nvm-windows<\/strong><\/h3>\n\n\n\n<p>We can make use of the <strong>nvm-windows<\/strong> and NVM(Node Version Manager) tool to update Node version windows. Although there are several usage similarities, NVM and nvm-windows aren\u2019t the same.<\/p>\n\n\n\n<p>It is required that you uninstall any existing Node and npm versions, otherwise, there\u2019s a chance for versions to conflict. Make sure you also delete any existing installation directories for example (<strong>%ProgramFiles%\\nodejs<\/strong>)<\/p>\n\n\n\n<p>Click here to download the <a href=\"https:\/\/github.com\/coreybutler\/nvm-windows\/releases\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>nvm-setup.zip file<\/strong><\/a> and run the latest installer.<\/p>\n\n\n\n<p>Now, jump to your Command Prompt or PowerShell terminal. Remember to <strong>Run it as Administrator<\/strong> because the utility runs in an Admin shell.<\/p>\n\n\n\n<p><strong>Start by installing the LTS (long-term supported) version, let\u2019s say we want to install 14.17.1:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nnvm install 14.17.1\n<\/pre><\/div>\n\n\n<p><strong>Next, switch to the version you just installed:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nnvm use 14.17.1\n<\/pre><\/div>\n\n\n<p><strong>Or, you can choose to simply install whatever is the latest version:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nnvm install latest\n<\/pre><\/div>\n\n\n<p><strong>To view a list of installed Node.js versions, run this:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nnvm list\n<\/pre><\/div>\n\n\n<p><strong>To view a list of versions available for download, run this:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nnvm list available\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">Different Ways to Update NodeJS on Linux (or macOS)<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Node Version Manager<\/h3>\n\n\n\n<p>A Node version manager is a tool or a utility that enables developers to install different versions of Node.js and switch impeccably between them.<\/p>\n\n\n\n<p>There are two Node version managers to choose from for Linux or MacOS, <strong>nvm or n<\/strong>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>nvm<\/strong><\/h4>\n\n\n\n<p><strong>nvm <\/strong>is nothing but a script-based version manager of Node.js. You can update your version of Node.js on Linux or MacOS with Wget or cURL.<\/p>\n\n\n\n<p>Let\u2019s say we want to install the v0.38.0 of nvm, in this example.<\/p>\n\n\n\n<p><strong>To update with Wget, run this command:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nwget -qO- https:\/\/raw.githubusercontent.com\/nvm-sh\/nvm\/v0.38.0\/install.sh | bash\n<\/pre><\/div>\n\n\n<p><strong>To update with cURL, run this command:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ncurl -o- https:\/\/raw.githubusercontent.com\/nvm-sh\/nvm\/v0.38.0\/install.sh | bash\n<\/pre><\/div>\n\n\n<p>These commands will also let you clone the repo to <strong>~\/.nvm<\/strong> in a way to let you make changes to your bash profile and gives you access to nvm globally around your system.<\/p>\n\n\n\n<p><strong>Let us check if the installation was successful:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ncommand \u2013v nvm\n<\/pre><\/div>\n\n\n<p>If installed properly, it will spit out <strong>nvm<\/strong>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>n<\/strong><\/h4>\n\n\n\n<p>We have already seen how we can upgrade Node.js on MacOS with n. These steps that follow are for Linux.<\/p>\n\n\n\n<p><strong>Let us first clear any cache that\u2019s present:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nnpm cache clean \u2013f\n<\/pre><\/div>\n\n\n<p><strong>Installing n globally:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nnpm install -g n\n<\/pre><\/div>\n\n\n<p><strong>Now that we have n installed, let\u2019s install the latest stable version of Node:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nn stable\n<\/pre><\/div>\n\n\n<p><strong>You may even choose to install the latest features by:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nn latest\n<\/pre><\/div>\n\n\n<p><strong>To download a specific version, you can simply do this:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nn 14.17.1\n<\/pre><\/div>\n\n\n<p><strong>To see a list of downloaded versions on your machine:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nn\n<\/pre><\/div>\n\n\n<p><strong>To upgrade to the latest LTS version:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nn lts\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">Updating NodeJS using a Node Installer<\/h2>\n\n\n\n<p>Although this is the least recommended way to perform a version update for Node.js, it is still a possible solution if for some reason you face issues with any steps above.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img decoding=\"async\" width=\"983\" height=\"468\" src=\"https:\/\/codeforgeek.com\/wp-content\/uploads\/2021\/06\/node_installers_win_mac_linux.png\" alt=\"Node Installers Win Mac Linux\" class=\"wp-image-8916\" srcset=\"https:\/\/codeforgeek.com\/wp-content\/uploads\/2021\/06\/node_installers_win_mac_linux.png 983w, https:\/\/codeforgeek.com\/wp-content\/uploads\/2021\/06\/node_installers_win_mac_linux-300x143.png 300w, https:\/\/codeforgeek.com\/wp-content\/uploads\/2021\/06\/node_installers_win_mac_linux-768x366.png 768w\" sizes=\"(max-width: 983px) 100vw, 983px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Updating Node.js with Installer on Linux<\/strong><\/h3>\n\n\n\n<p>Simply jump to the <a href=\"https:\/\/nodejs.org\/en\/download\/\" data-type=\"URL\" data-id=\"https:\/\/nodejs.org\/en\/download\/\" target=\"_blank\" rel=\"noreferrer noopener\">downloads page<\/a> where you will find many Linux binary packages. Select your preferred installer.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Updating Node.js with Installer on Windows &amp; macOS<\/strong><\/h3>\n\n\n\n<p>Based on your system, you can select from any of the two highlighted installers for Windows and macOS.<\/p>\n\n\n\n<p>Run the installation wizard. Normally, there\u2019s nothing of the defaults that you would have to change.<\/p>\n\n\n\n<p>After you&#8217;re done, it will have flawlessly completed installing Node.js and upgrading your version of Node.js by replacing it with the new one.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Summary <\/h2>\n\n\n\n<p>Node.js is updating regularly to provide better security, new features and more stability. When a new version is presented, the documentation is also updated, and to follow up on that documentation you must install the latest version. For example, if you are using an old version and try to access a method by reading the documentation of the latest version will cause an error. So updating to the latest version is a great way to solve this conflict. We hope this tutorial helps you update to the latest version of Node.js on your respective operating system.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Reference<\/h2>\n\n\n\n<p><a href=\"https:\/\/nodejs.org\/en\/download\/\" target=\"_blank\" rel=\"noopener\">https:\/\/nodejs.org\/en\/download\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Node.js is an extremely vast, server-side open-source JavaScript environment that runs on Chrome\u2019s V8 JS engine. This enormousness of Node.js has resulted in a huge and active community of users, flooding contributions every second. Node.js is an emerging technology and it provides regular updates, it is essential to keep updating to the latest versions of [&hellip;]<\/p>\n","protected":false},"author":70,"featured_media":8913,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_surecart_dashboard_logo_width":"180px","_surecart_dashboard_show_logo":true,"_surecart_dashboard_navigation_orders":true,"_surecart_dashboard_navigation_invoices":true,"_surecart_dashboard_navigation_subscriptions":true,"_surecart_dashboard_navigation_downloads":true,"_surecart_dashboard_navigation_billing":true,"_surecart_dashboard_navigation_account":true,"_uag_custom_page_level_css":"","footnotes":""},"categories":[14],"tags":[],"class_list":["post-8912","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-nodejs"],"blocksy_meta":[],"uagb_featured_image_src":{"full":["https:\/\/codeforgeek.com\/wp-content\/uploads\/2021\/06\/update_node_featured_image.png",1200,500,false],"thumbnail":["https:\/\/codeforgeek.com\/wp-content\/uploads\/2021\/06\/update_node_featured_image-150x150.png",150,150,true],"medium":["https:\/\/codeforgeek.com\/wp-content\/uploads\/2021\/06\/update_node_featured_image-300x125.png",300,125,true],"medium_large":["https:\/\/codeforgeek.com\/wp-content\/uploads\/2021\/06\/update_node_featured_image-768x320.png",768,320,true],"large":["https:\/\/codeforgeek.com\/wp-content\/uploads\/2021\/06\/update_node_featured_image-1024x427.png",1024,427,true],"1536x1536":["https:\/\/codeforgeek.com\/wp-content\/uploads\/2021\/06\/update_node_featured_image.png",1200,500,false],"2048x2048":["https:\/\/codeforgeek.com\/wp-content\/uploads\/2021\/06\/update_node_featured_image.png",1200,500,false]},"uagb_author_info":{"display_name":"Aneesha S","author_link":"https:\/\/codeforgeek.com\/author\/aneesha\/"},"uagb_comment_info":0,"uagb_excerpt":"Node.js is an extremely vast, server-side open-source JavaScript environment that runs on Chrome\u2019s V8 JS engine. This enormousness of Node.js has resulted in a huge and active community of users, flooding contributions every second. Node.js is an emerging technology and it provides regular updates, it is essential to keep updating to the latest versions of&hellip;","_links":{"self":[{"href":"https:\/\/codeforgeek.com\/wp-json\/wp\/v2\/posts\/8912","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codeforgeek.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codeforgeek.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codeforgeek.com\/wp-json\/wp\/v2\/users\/70"}],"replies":[{"embeddable":true,"href":"https:\/\/codeforgeek.com\/wp-json\/wp\/v2\/comments?post=8912"}],"version-history":[{"count":0,"href":"https:\/\/codeforgeek.com\/wp-json\/wp\/v2\/posts\/8912\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codeforgeek.com\/wp-json\/wp\/v2\/media\/8913"}],"wp:attachment":[{"href":"https:\/\/codeforgeek.com\/wp-json\/wp\/v2\/media?parent=8912"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeforgeek.com\/wp-json\/wp\/v2\/categories?post=8912"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeforgeek.com\/wp-json\/wp\/v2\/tags?post=8912"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}