<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: brunohafonso</title>
    <description>The latest articles on DEV Community by brunohafonso (@brunohafonso).</description>
    <link>https://dev.to/brunohafonso</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F324605%2Ff3d44652-d508-45dd-8e3a-3f34254ebd48.jpeg</url>
      <title>DEV Community: brunohafonso</title>
      <link>https://dev.to/brunohafonso</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/brunohafonso"/>
    <language>en</language>
    <item>
      <title>How to install Node.JS: Secrets and Best Practices for Every Platform Revealed</title>
      <dc:creator>brunohafonso</dc:creator>
      <pubDate>Tue, 11 Jun 2024 14:08:14 +0000</pubDate>
      <link>https://dev.to/brunohafonso/how-to-install-nodejs-secrets-and-best-practices-for-every-platform-revealed-31di</link>
      <guid>https://dev.to/brunohafonso/how-to-install-nodejs-secrets-and-best-practices-for-every-platform-revealed-31di</guid>
      <description>&lt;h1&gt;
  
  
  Overview
&lt;/h1&gt;

&lt;p&gt;Node works on many platforms, there are a lot of ways to install it,&lt;br&gt;
However, there are some practices we must follow while installing Node on Windows, Linux, and MacOS machines.&lt;/p&gt;
&lt;h1&gt;
  
  
  Learning Objectives
&lt;/h1&gt;

&lt;p&gt;At the final of this article you will be able to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Discover the best way to install and use Node in each platform.&lt;/li&gt;
&lt;li&gt;Understand what executables are installed&lt;/li&gt;
&lt;li&gt;Manage multiple Node versions&lt;/li&gt;
&lt;li&gt;How to set a default Node version on your Machine.&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
  
  
  Best practices to install Node on different platforms
&lt;/h1&gt;

&lt;p&gt;The most common way to install Node is by using an OS package manager but this is not the best way to do it due to the reasons below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;OS package manager tends to lag behind the faster Node.JS release cycle (the latest versions cannot be available on the OS package manager)&lt;/li&gt;
&lt;li&gt;The placement of binaries, folders, and files isn't standardized across OS package managers which can cause incompatibility issues.&lt;/li&gt;
&lt;li&gt;Installing Node using a package manager requires the use of

&lt;code&gt;sudo&lt;/code&gt;

on Non-Windows systems when we want to install a global package using the &lt;code&gt;npm&lt;/code&gt;, and it's a critical security issue because we grant root privileges to the install process of third-party libraries.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We can also install Node directly from the Node.JS website but, Again a Non-Windows system requires the root privileges for installing global packages.&lt;/p&gt;
&lt;h1&gt;
  
  
  Installing NVM (Non-Windows systems)
&lt;/h1&gt;

&lt;p&gt;The recommended way to install Node in Non-windows systems is by using a Node Version Manager, in particular &lt;a href="https://github.com/nvm-sh/nvm"&gt;nvm&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To install NVM we must use the install script available on &lt;a href="https://github.com/nvm-sh/nvm/blob/v0.39.5/install.sh"&gt;Github&lt;/a&gt;, if you need to use a newer version you just need to change the version in the URL.&lt;/p&gt;

&lt;p&gt;If you have curl installed already (it usually is) run the command bellow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-o-&lt;/span&gt; htt‌ps://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;If using zsh (e.g., on newer macOS releases) the bash part of the command can be replaced with zsh.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can download and execute the file as well:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;install.sh | bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Again you can replace &lt;code&gt;bash&lt;/code&gt; by &lt;code&gt;zsh&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To check if the installation was successful use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;command&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; nvm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;It should output &lt;code&gt;nvm&lt;/code&gt;.&lt;br&gt;
&lt;br&gt; If this fails on Linux, close and reopen the terminal and try running the command again.&lt;br&gt;
&lt;br&gt; On macOS see GitHub for in-depth &lt;a href="https://github.com/nvm-sh/nvm#troubleshooting-on-macos"&gt;troubleshooting instructions&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now that you have the &lt;code&gt;nvm&lt;/code&gt; installed, go ahead and install a Node version by using this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nvm &lt;span class="nb"&gt;install &lt;/span&gt;20
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will install a Node version respecting the major version but, minor and patches will change, if you want to install a specific version you must provide the entire version number.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can install any version you want using this command above.&lt;br&gt;
By default the nvm will set the first Node version you installed as the default, but you can override the default version using the command &lt;code&gt;nvm alias default 20&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To check if the installation was successful run this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's it now you have the Node installed on your machine following the best practices.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing NVS (Windows systems)
&lt;/h2&gt;

&lt;p&gt;While we have &lt;code&gt;nvm&lt;/code&gt; for Linux and MacOS, and an unaffiliated &lt;code&gt;nvm-windows&lt;/code&gt; version manager, the recommended version manager for Windows is &lt;a href="https://github.com/jasongin/nvs"&gt;nvs&lt;/a&gt;, it is cross-platform and can be used on Linux and MacOS, but on these systems the most common is &lt;code&gt;nvm&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To install &lt;code&gt;nvs&lt;/code&gt; use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;winget&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;install&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;jasongin.nvs&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or using chocolatey&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;choco&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;install&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;nvs&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can visit the &lt;a href="https://github.com/jasongin/nvs/releases"&gt;nvs releases page&lt;/a&gt;, and download the &lt;code&gt;msi&lt;/code&gt; `file of the last release to install it.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;On the first time running &lt;code&gt;nvs&lt;/code&gt;, the command may ask for agreement to terms.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Once installed, install the latest version 20 release:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;bash&lt;br&gt;
nvs add 20&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;then execute the command below to select the installed version&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;bash&lt;br&gt;
nvs use 20&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can install any version you want using the commands above.&lt;br&gt;
By default the &lt;code&gt;nvs&lt;/code&gt; doesn't set a Node version as default, but you can set the default version using the command &lt;code&gt;nvs link 20&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To confirm if Node was installed successfully use this command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;bash&lt;br&gt;
node -v&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;bash&lt;br&gt;
npm -v&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And that's it now you have the Node installed on your machine following the best practices.&lt;/p&gt;

&lt;h1&gt;
  
  
  Which binaries are included with Node ?
&lt;/h1&gt;

&lt;p&gt;The Node installation includes the &lt;code&gt;npm&lt;/code&gt; installation which is the Node package manager that we use to manage the third-party libraries that we will use on the projects or as a global package on our machines. &lt;/p&gt;

</description>
      <category>node</category>
      <category>javascript</category>
      <category>tutorial</category>
      <category>certification</category>
    </item>
    <item>
      <title>My Journey to get the OpenJS Node.js Services Developer (JSNSD) certification</title>
      <dc:creator>brunohafonso</dc:creator>
      <pubDate>Tue, 11 Jun 2024 13:44:59 +0000</pubDate>
      <link>https://dev.to/brunohafonso/my-journey-to-get-the-openjs-nodejs-services-developer-jsnsd-certification-34nm</link>
      <guid>https://dev.to/brunohafonso/my-journey-to-get-the-openjs-nodejs-services-developer-jsnsd-certification-34nm</guid>
      <description>&lt;p&gt;Around a year ago, I challenged myself to achieve the two Node.JS certifications offered by the &lt;a href="https://openjsf.org/"&gt;OpenJS Foundation&lt;/a&gt;. However, I could only set aside some time to focus on it and organize my routine to study the required content. &lt;/p&gt;

&lt;p&gt;I am also improving my English skills and would combine the two by using a tech blog to post my journey. This blog would be a notebook where I can easily review the content and clear my doubts. &lt;/p&gt;

&lt;p&gt;This is the first post of many, Where I will share my journey to get both certifications, starting with the &lt;a href="https://training.linuxfoundation.org/certification/jsnsd/"&gt;JSNSD certification&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;I hope you enjoy this series of posts, but if not, that's okay - I will finish them anyway.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>certification</category>
      <category>routine</category>
    </item>
  </channel>
</rss>
