<?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>Forem: Aditya </title>
    <description>The latest articles on Forem by Aditya  (@astrobotme).</description>
    <link>https://forem.com/astrobotme</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%2F715160%2F4af7c093-d1d9-460e-bd59-c0bf8b1a024a.png</url>
      <title>Forem: Aditya </title>
      <link>https://forem.com/astrobotme</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/astrobotme"/>
    <language>en</language>
    <item>
      <title>Var Type Identifier/Keyword of Java</title>
      <dc:creator>Aditya </dc:creator>
      <pubDate>Sun, 23 Feb 2025 17:13:17 +0000</pubDate>
      <link>https://forem.com/astrobotme/var-type-identifierkeyword-of-java-32jf</link>
      <guid>https://forem.com/astrobotme/var-type-identifierkeyword-of-java-32jf</guid>
      <description>&lt;p&gt;Java 10 added the &lt;strong&gt;var keyword&lt;/strong&gt;, which allows you to declare local variables without explicitly defining their type. &lt;strong&gt;Instead, the compiler deduces the type from the variable's assigned value&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Hello, World!"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// Compiler infers type as String&lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;                &lt;span class="c1"&gt;// Compiler infers type as int&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Key Points About var:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;var&lt;/strong&gt; can only be used for &lt;strong&gt;local variables&lt;/strong&gt; (e.g., within methods, loops, or blocks).&lt;/li&gt;
&lt;li&gt;It cannot be used for &lt;strong&gt;method parameters&lt;/strong&gt;, &lt;strong&gt;constructor parameters&lt;/strong&gt; ,&lt;strong&gt;return types&lt;/strong&gt; or &lt;strong&gt;fields&lt;/strong&gt; (class-level variables).&lt;/li&gt;
&lt;li&gt;The type of the variable is &lt;strong&gt;inferred at compile-time&lt;/strong&gt;, not runtime.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;var is not a reserved keyword&lt;/strong&gt; but a &lt;strong&gt;reserved type name&lt;/strong&gt;, meaning it &lt;strong&gt;cannot be used as an identifier&lt;/strong&gt; in contexts where a type is expected. &lt;/li&gt;
&lt;li&gt;Java remains statically typed; &lt;strong&gt;var does not introduce dynamic typing&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Example Proper usage of Var
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;VarExample&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Hello, Java 10"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// String inferred&lt;/span&gt;
        &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;of&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;   &lt;span class="c1"&gt;// List&amp;lt;Integer&amp;gt; inferred&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;

        &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;map&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;HashMap&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Integer&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;();&lt;/span&gt;
        &lt;span class="n"&gt;map&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;put&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Age"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Points to Ponder
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;3.12&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; 
&lt;span class="c1"&gt;// What is the type of number?  &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Answer: The compiler infers &lt;strong&gt;number&lt;/strong&gt; as &lt;strong&gt;double&lt;/strong&gt;, not &lt;strong&gt;float&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Why double and Not float?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;In Java, decimal literals are of type double by default, unless you explicitly specify otherwise.&lt;/li&gt;
&lt;li&gt;To assign a float, you must append an f or F to the literal. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;3.12f&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// Now the type is float&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Some Interesting Facts about var Keyword
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;var&lt;/code&gt; is Not Reserved Keyword&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;var&lt;/code&gt; can't be used without initialization
Unlike regular variables, var must be initialized at declaration because the compiler needs a type to infer.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;❌ Invalid Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// ❌ Compilation error: Cannot use 'var' without an initializer&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ Valid Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// ✅ Compiler infers int&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;var&lt;/code&gt; is Just Syntax Sugar – No Performance Overhead
The Java compiler erases var during compilation and replaces it with the inferred type.
At runtime, there is no difference in performance between var and explicit types.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;📌 Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ArrayList&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ After compilation, it becomes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;ArrayList&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ArrayList&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;var&lt;/code&gt; can't have a &lt;strong&gt;null&lt;/strong&gt; Without Explicit Type
The compiler cannot infer a type from null, so var must have an explicit value.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;❌ Invalid Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// ❌ Compilation error: Cannot infer type from 'null'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ Valid Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// ✅ Explicit cast allows inference&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🎯 Conclusion:
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;var&lt;/strong&gt; keyword is a powerful feature that makes Java code more concise while preserving static typing. However, it should be used carefully to maintain code readability and avoid ambiguity.&lt;/p&gt;

&lt;h2&gt;
  
  
  End
&lt;/h2&gt;

&lt;p&gt;If you have reached till the end, Thanks for giving this article a read. &lt;/p&gt;

&lt;p&gt;If you liked this article, &lt;strong&gt;drop a like or comment&lt;/strong&gt; ❤ or &lt;strong&gt;maybe share it in your community&lt;/strong&gt; :) , You can also drop me a follow on &lt;a href="https://x.com/Astrobot_me" rel="noopener noreferrer"&gt;X&lt;/a&gt; 🐤 or &lt;a href="https://linkedin.com/in/astro-adityaraj/" rel="noopener noreferrer"&gt;Linked In&lt;/a&gt; 👨‍🏫&lt;/p&gt;

</description>
      <category>java</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Mastering Node.js Version Management with Fast Node Manager (fnm)</title>
      <dc:creator>Aditya </dc:creator>
      <pubDate>Sat, 25 Jan 2025 17:29:59 +0000</pubDate>
      <link>https://forem.com/astrobotme/mastering-nodejs-version-management-with-fast-node-manager-fnm-17ji</link>
      <guid>https://forem.com/astrobotme/mastering-nodejs-version-management-with-fast-node-manager-fnm-17ji</guid>
      <description>&lt;h2&gt;
  
  
  Introduction to Node.js Version Management
&lt;/h2&gt;

&lt;p&gt;Managing multiple Node.js versions can be challenging for developers who work on different projects with varying runtime requirements. While traditional installers limit you to a single Node.js version, Fast Node Manager (fnm) provides a flexible, efficient solution for switching between Node.js versions seamlessly.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is fnm?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;fnm&lt;/strong&gt; is a fast and simple Node.js manager built in Rust ⚡&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Use fnm?
&lt;/h2&gt;

&lt;p&gt;Before diving into the installation and usage, let's understand the advantages of fnm:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Quick Version Switching&lt;/strong&gt;: Instantly change Node.js versions without complex uninstallation processes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Project-Specific Configurations&lt;/strong&gt;: Set different Node.js versions for different projects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lightweight and Fast&lt;/strong&gt;: Unlike some other version managers, fnm is designed to be minimal and performant.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cross-Platform Support&lt;/strong&gt;: Works consistently across Windows, macOS, and Linux.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step-by-Step Guide to Installing fnm
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Installation Methods
&lt;/h3&gt;

&lt;h4&gt;
  
  
  For macOS and Linux:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Using curl&lt;/span&gt;
curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://fnm.vercel.app/install | bash

&lt;span class="c"&gt;# Alternative method using shell script&lt;/span&gt;
wget &lt;span class="nt"&gt;-qO-&lt;/span&gt; https://fnm.vercel.app/install | bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  For Windows:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Using winget&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&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;Schniz.fnm&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c"&gt;# Using scoop&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;scoop&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;fnm&lt;/span&gt;&lt;span class="w"&gt;
&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;&lt;span class="nb"&gt;eval&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;fnm &lt;span class="nb"&gt;env&lt;/span&gt; &lt;span class="nt"&gt;--use-on-cd&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. PowerShell Configurations
&lt;/h3&gt;

&lt;p&gt;Add the following to the end of your PowerShell profile file :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fnm &lt;span class="nb"&gt;env&lt;/span&gt; &lt;span class="nt"&gt;--use-on-cd&lt;/span&gt; &lt;span class="nt"&gt;--shell&lt;/span&gt; powershell | Out-String | Invoke-Expression
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You have to find the Powershell Profile file or create one if it's not already present, you can find the instructions below&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For macOS/Linux, the profile is located at&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;~/.config/powershell/Microsoft.PowerShell_profile.ps1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For Windows location is either:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;%userprofile%&lt;span class="se"&gt;\D&lt;/span&gt;ocuments&lt;span class="se"&gt;\W&lt;/span&gt;indowsPowerShell&lt;span class="se"&gt;\M&lt;/span&gt;icrosoft.PowerShell_profile.ps1 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Powershell 5&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;%userprofile%&lt;span class="se"&gt;\D&lt;/span&gt;ocuments&lt;span class="se"&gt;\P&lt;/span&gt;owerShell&lt;span class="se"&gt;\M&lt;/span&gt;icrosoft.PowerShell_profile.ps1 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the profile is not present and &lt;strong&gt;to create the profile file&lt;/strong&gt; you can run this in PowerShell:&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="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;-not&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;Test-Path &lt;span class="nv"&gt;$profile&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; New-Item &lt;span class="nv"&gt;$profile&lt;/span&gt; &lt;span class="nt"&gt;-Force&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To edit your profile run this in PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Invoke-Item &lt;span class="nv"&gt;$profile&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Invoke it and then add the first PowerShell command to the end of your PowerShell Profile&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This enables automatic Node.js version switching and you can easily use multiple node js versions.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Basic fnm setup flow
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Download and install fnm:&lt;/span&gt;
winget &lt;span class="nb"&gt;install &lt;/span&gt;Schniz.fnm
&lt;span class="c"&gt;# Download and install Node.js:&lt;/span&gt;
fnm &lt;span class="nb"&gt;install &lt;/span&gt;22
&lt;span class="c"&gt;# Select the version&lt;/span&gt;
fnm use 22  
&lt;span class="c"&gt;# Verify the Node.js version:&lt;/span&gt;
node &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="c"&gt;# Should print "v22.13.1".&lt;/span&gt;
&lt;span class="c"&gt;# Verify npm version:&lt;/span&gt;
npm &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="c"&gt;# Should print "10.9.2".&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you face any error such as "&lt;strong&gt;can't find fnm's environment variables"&lt;/strong&gt;, then it may be related to configurations of the shell you are using!&lt;/p&gt;

&lt;h3&gt;
  
  
  Installing Node.js Versions
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install the latest LTS version&lt;/span&gt;
fnm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--lts&lt;/span&gt;
fnm i &lt;span class="nt"&gt;--lts&lt;/span&gt;

&lt;span class="c"&gt;# Install a specific version&lt;/span&gt;
fnm &lt;span class="nb"&gt;install &lt;/span&gt;16.14.2

&lt;span class="c"&gt;# Install the latest version&lt;/span&gt;
fnm &lt;span class="nb"&gt;install &lt;/span&gt;latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Managing Installed Versions
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# List all installed Node.js versions&lt;/span&gt;
fnm &lt;span class="nb"&gt;ls&lt;/span&gt;

&lt;span class="c"&gt;# List all remote Node.js versions&lt;/span&gt;
fnm ls-remote

&lt;span class="c"&gt;# Set a default global Node.js version&lt;/span&gt;
fnm default 22.13.1

&lt;span class="c"&gt;# Use a specific version in the current shell&lt;/span&gt;
fnm use 22.13.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fului7ks5ssbk2v3ub34h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fului7ks5ssbk2v3ub34h.png" alt="fnm remote" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Current Node Version
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fnm current
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F44x0vwq25d57ahm90ut1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F44x0vwq25d57ahm90ut1.png" alt="fnm current" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Version Aliasing
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Syntax to set an alias for a version is&lt;/span&gt;
fnm &lt;span class="nb"&gt;alias&lt;/span&gt; &amp;lt;version&amp;gt; &amp;lt;name&amp;gt;
fnm &lt;span class="nb"&gt;alias &lt;/span&gt;22.13.1 my-nodeproject

&lt;span class="c"&gt;# Use the aliased version&lt;/span&gt;
fnm use my-nodeproject

&lt;span class="c"&gt;# To set the default alias &lt;/span&gt;
fnm default 22.13.1

&lt;span class="c"&gt;# To Unalias &lt;/span&gt;
fnm &lt;span class="nb"&gt;unalias&lt;/span&gt; &amp;lt;name&amp;gt;
fnm &lt;span class="nb"&gt;unalias &lt;/span&gt;my-nodeproject

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Project-Specific Version Management
&lt;/h2&gt;

&lt;p&gt;Create a &lt;code&gt;.node-version&lt;/code&gt; file in your project root to automatically use a specific Node.js version:&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="c"&gt;# In your project directory&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"22.13.1"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; .node-version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, when you enter the project directory, fnm will automatically switch to the specified version.&lt;/p&gt;

&lt;h2&gt;
  
  
  Best Practices
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Always use &lt;strong&gt;LTS (Long Term Support)&lt;/strong&gt; versions for production projects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Regularly update fnm&lt;/strong&gt; to get the latest features and improvements.&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;&lt;code&gt;.node-version&lt;/code&gt; or &lt;code&gt;.nvmrc&lt;/code&gt;&lt;/strong&gt; files to maintain consistency across development teams.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Troubleshooting
&lt;/h2&gt;

&lt;p&gt;Again, If you encounter issues:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ensure fnm is correctly added to your PATH&lt;/li&gt;
&lt;li&gt;Verify shell configuration&lt;/li&gt;
&lt;li&gt;Check fnm version with &lt;code&gt;fnm --version&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Fast Node Manager simplifies Node.js version management, offering developers a flexible, efficient tool for handling multiple runtime environments. By following these steps, you can easily switch between Node.js versions and maintain project-specific configurations.&lt;/p&gt;

&lt;p&gt;If you liked this article, &lt;strong&gt;drop a like or comment ** ❤ or **maybe share it in your community&lt;/strong&gt; :). You can also drop me a follow on &lt;a href="https://x.com/Astrobot_me" rel="noopener noreferrer"&gt;X&lt;/a&gt; 🐤 or &lt;a href="https://linkedin.com/in/astro-adityaraj/" rel="noopener noreferrer"&gt;Linked In&lt;/a&gt; 👨‍🏫&lt;/p&gt;

</description>
      <category>node</category>
      <category>fnm</category>
      <category>javascript</category>
      <category>npm</category>
    </item>
  </channel>
</rss>
