<?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: Erik Harutyunyan</title>
    <description>The latest articles on Forem by Erik Harutyunyan (@01erik33).</description>
    <link>https://forem.com/01erik33</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%2F2058636%2Fff96dac5-41c1-4589-a7c0-b2bd24b63125.png</url>
      <title>Forem: Erik Harutyunyan</title>
      <link>https://forem.com/01erik33</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/01erik33"/>
    <language>en</language>
    <item>
      <title>Automate Like a Pro: Mastering Component Generation in React with Generate React CLI</title>
      <dc:creator>Erik Harutyunyan</dc:creator>
      <pubDate>Sun, 15 Sep 2024 08:03:31 +0000</pubDate>
      <link>https://forem.com/01erik33/automate-like-a-pro-mastering-component-generation-in-react-with-generate-react-cli-51h</link>
      <guid>https://forem.com/01erik33/automate-like-a-pro-mastering-component-generation-in-react-with-generate-react-cli-51h</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Simplify React component creation, automate file generation, and customize templates with Generate React CLI. Boost productivity and maintain code consistency effortlessly!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&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%2Frpktekfp930yuuioy7o5.jpg" 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%2Frpktekfp930yuuioy7o5.jpg" alt=" " width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Being a React developer is exciting. With its component-based architecture, React has revolutionized the way we build user interfaces.&lt;/p&gt;

&lt;p&gt;Creating new components manually in React can be a tedious and time-consuming task. As a software engineer or a front-end developer, you might often find yourself copying, pasting, and renaming files for every new component you create. This is where automating React components generation comes in. This article is a comprehensive guide that will help you master the process of generating React components automatically using a tool called "&lt;strong&gt;Generate React CLI.&lt;/strong&gt;"&lt;/p&gt;




&lt;h2&gt;
  
  
  A Brief Introduction to React Components
&lt;/h2&gt;

&lt;p&gt;React is a popular JavaScript library for building user interfaces. It allows developers to create large web applications that can change data without reloading the page. The main building blocks of a React application are React components.&lt;/p&gt;

&lt;p&gt;React components are independent, reusable pieces of code. They serve the same purpose as JavaScript functions, but work in isolation and return HTML via a render function.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Need for Automating React Components Generation
&lt;/h2&gt;

&lt;p&gt;Automating the generation of React components can significantly streamline the development process, especially for seasoned front-end developers. Manual creation of these components, although initially engaging for novices, can quickly become burdensome and time-consuming. This typically involves duplicating extensive code, configuring test and style files, and preparing Storybook files, among other repetitive actions.&lt;/p&gt;

&lt;p&gt;With automation, developers can bypass the tedium of repetitive tasks, enabling quicker and more efficient code production. By automating component generation, developers can focus more on complex &lt;br&gt;
problem-solving and creative aspects of development, thus optimizing productivity and project quality.&lt;/p&gt;


&lt;h2&gt;
  
  
  Introducing Generate React CLI
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.npmjs.com/package/generate-react-cli" rel="noopener noreferrer"&gt;Generate React CLI&lt;/a&gt; is an open-source tool that automates the creation of React components. It generates a component folder and files for each component, including tests, styles, and Storybook files. This tool allows you to customize your components and create your component types and templates, making it a flexible solution for React developers.&lt;/p&gt;

&lt;p&gt;This tool is available as an NPM package and can be installed into any React project. It can be used as a dependency or as a command in the console.&lt;/p&gt;

&lt;p&gt;To use Generate React CLI, you need to have Node version 18.x or higher and NPM version 10.x or greater installed on your computer. You can install Generate React CLI as a dev dependency using the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;generate-react-cli &lt;span class="nt"&gt;--save-dev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn add &lt;span class="nt"&gt;-D&lt;/span&gt; generate-react-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively, you can run it directly using npx:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx generate-react-cli component Box
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Note: npx is a package runner tool that ships with npm 5.2+.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Using Generate React CLI
&lt;/h2&gt;

&lt;p&gt;A simple command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx generate-react-cli component Box
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Executed in the console begins the magic. A brief Q&amp;amp;A session is initiated, inquiring about your usage of TypeScript, styled-components, testing, and a lot more. And it creates a new React component named Box. The answers to these questions are stored in a generate-react-cli.json config file at the root of your project, ready for future references and customizations.&lt;/p&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%2Fe47juo5xbz4aregk6386.jpg" 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%2Fe47juo5xbz4aregk6386.jpg" alt=" " width="800" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is an example of the &lt;strong&gt;generate-react-cli.json&lt;/strong&gt; config file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"usesTypeScript"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"usesStyledComponents"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"testLibrary"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Testing Library"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"component"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"default"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"path"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"src/components"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"withStyle"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"withTest"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"withStory"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"withLazy"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Override the default configuration with options
&lt;/h2&gt;

&lt;p&gt;You can override some of the default configuration rules using one-off commands. For example, if you have set withTest to be true in the component.default property, you can override it like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx generate-react-cli component Box &lt;span class="nt"&gt;--withTest&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you have set withTest to be false, you can override it like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx generate-react-cli component Box &lt;span class="nt"&gt;--withTest&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you don't pass any options, the default values that you have set in the generate-react-cli.json config file under the component.default will be used.&lt;/p&gt;

&lt;p&gt;Other options can be found on the &lt;a href="https://github.com/arminbro/generate-react-cli?tab=readme-ov-file#generate-components" rel="noopener noreferrer"&gt;Generate React CLI GitHub repository&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Generate React CLI as a dev dependency
&lt;/h2&gt;

&lt;p&gt;What is the disadvantage of using the utility as such a long command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx generate-react-cli&lt;/code&gt; component Box, this is that everyone inside the team must remember all this history to use and so on. It is better to just install generate-react-cli as a dev dependency.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i &lt;span class="nt"&gt;--save-dev&lt;/span&gt; generate-react-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn add &lt;span class="nt"&gt;-D&lt;/span&gt; generate-react-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we obtained the dependence of D, we can create an npm script and the same story is a little shorter.&lt;/p&gt;

&lt;p&gt;Suppose we have a script called component, and to create components we can now say either&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run component ComponentName
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn component ComponentName
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and create the component name, the same thing happens, just a little shorter.&lt;/p&gt;

&lt;p&gt;Also, no one needs to memorize a long command. We can always go to the package.json and execute the command that is there.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"component-generate-react-cli"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"private"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"0.0.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"module"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"dev"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"vite"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"vite build"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"lint"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"preview"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"vite preview"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"component"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"generate-react component"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"dependencies"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"react"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^18.2.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"react-dom"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^18.2.0"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"devDependencies"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"@types/react"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^18.2.66"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"@types/react-dom"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^18.2.22"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"@vitejs/plugin-react-swc"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^3.5.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"eslint"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^8.57.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"eslint-plugin-react"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^7.34.1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"eslint-plugin-react-hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^4.6.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"eslint-plugin-react-refresh"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^0.4.6"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"vite"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^5.2.0"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Customize Component Templates
&lt;/h2&gt;

&lt;p&gt;Generate React CLI also provides a customTemplates object where the keys represent the file type, and the values are paths pointing to your custom template's location in your project.&lt;/p&gt;

&lt;p&gt;Template File Examples:&lt;/p&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%2Fgpgyr4r8ld1sg6cox1r4.jpg" 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%2Fgpgyr4r8ld1sg6cox1r4.jpg" alt=" " width="800" height="229"&gt;&lt;/a&gt;&lt;/p&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%2Flrfzhyj52pj9ih0k4tb5.jpg" 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%2Flrfzhyj52pj9ih0k4tb5.jpg" alt=" " width="800" height="363"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;An example of a customTemplates object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"usesTypeScript"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"usesStyledComponents"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"testLibrary"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Testing Library"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"component"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"default"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"customTemplates"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"component"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"templates/default/TemplateName.jsx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"style"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"templates/default/TemplateName.styled.jsx"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"path"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"src/components"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"withStyle"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"withTest"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"withStory"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"withLazy"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; the TemplateName keyword, as this keyword is used by GRC and will replace it with our component name based on one of the formats in which we entered the component name into the command as a filename. However, you can use the following keywords in your custom templates to properly format component names in your templates:&lt;/p&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%2Fzjkhytwb910nebmcdswb.jpg" 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%2Fzjkhytwb910nebmcdswb.jpg" alt=" " width="731" height="338"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Generate Custom Component Files
&lt;/h2&gt;

&lt;p&gt;When you use Generate React CLI, it automatically generates essential files for your component, such as styles, tests, stories, and lazy loading support. However, you have the flexibility to customize this process by editing the generate-react-cli.json configuration file.&lt;/p&gt;

&lt;p&gt;If you want additional files, you can specify them by adding new keys prefixed with "with" in the configuration. For instance, if you wish to include an index.js file for each component to streamline imports, you can enable this feature by setting "withIndex" to true and adding "index" to the "customTemplates" object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"usesTypeScript"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"usesStyledComponents"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"testLibrary"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Testing Library"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"component"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"default"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"customTemplates"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"component"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"templates/default/TemplateName.jsx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"style"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"templates/default/TemplateName.styled.jsx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"index"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"templates/default/index.jsx"&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"path"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"src/components"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"withStyle"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"withTest"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"withStory"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"withLazy"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"withIndex"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&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%2F8yq9qv95kctrn3leeve3.jpg" 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%2F8yq9qv95kctrn3leeve3.jpg" alt=" " width="800" height="180"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Similarly, we can create our own hook, let's say it will be called useTemplateName accordingly here we will have withHook: true&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"usesTypeScript"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"usesStyledComponents"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"testLibrary"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Testing Library"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"component"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"default"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"customTemplates"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"component"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"templates/default/TemplateName.jsx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"style"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"templates/default/TemplateName.styled.jsx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"index"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"templates/default/index.jsx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"hook"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"templates/default/useTemplateName.jsx"&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"path"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"src/components"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"withStyle"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"withTest"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"withStory"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"withLazy"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"withIndex"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"withHook"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&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%2Fpvtv9ubhcchc9k7q8w66.jpg" 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%2Fpvtv9ubhcchc9k7q8w66.jpg" alt=" " width="800" height="282"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Developing Personalized Component Types
&lt;/h2&gt;

&lt;p&gt;By default, the Generate React CLI uses component.default configuration rules to generate new components. However, we may want to generate other types of components that have their own set of configuration rules, such as pages or layout components.&lt;/p&gt;

&lt;p&gt;Additionally, we can also augment these types components with templates.&lt;br&gt;
You can do this by extending the generate-react-cli.json configuration file as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"usesTypeScript"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"usesStyledComponents"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"testLibrary"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Testing Library"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"component"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"default"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"customTemplates"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"component"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"templates/default/TemplateName.jsx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"style"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"templates/default/TemplateName.styled.jsx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"lazy"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"templates/default/TemplateName.lazy.jsx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"index"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"templates/default/index.jsx"&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"path"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"src/components"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"withStyle"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"withTest"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"withStory"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"withLazy"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"withIndex"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"page"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"customTemplates"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"component"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"templates/page/TemplateName.jsx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"lazy"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"templates/page/TemplateName.lazy.jsx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"style"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"templates/page/TemplateName.styled.jsx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"index"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"templates/page/index.jsx"&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"path"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"src/pages"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"withLazy"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"withStory"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"withStyle"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"withTest"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"withIndex"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"layout"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"customTemplates"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"component"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"templates/layout/TemplateName.jsx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"index"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"templates/layout/index.jsx"&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"path"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"src/layouts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"withIndex"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above configuration file, there are three types of components: default, page, and layout. Each type of component has its own configuration rules.&lt;br&gt;
We can generate a component of a particular type using the - type option:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx generate-react-cli component HomePage &lt;span class="nt"&gt;--type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;page
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above command generates a new React component of the type page with the name HomePage.&lt;/p&gt;

&lt;p&gt;We can also create our script for this by adding it to package.json to make it a bit faster and easier.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run page HomePage
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"component-generate-react-cli"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"private"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"0.0.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"module"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"dev"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"vite"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"vite build"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"lint"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"preview"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"vite preview"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"component"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"generate-react component"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"page"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"generate-react component  --type=page"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"layout"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"generate-react component  --type=layout"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"dependencies"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"react"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^18.2.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"react-dom"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^18.2.0"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"devDependencies"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"@types/react"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^18.2.66"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"@types/react-dom"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^18.2.22"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"@vitejs/plugin-react-swc"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^3.5.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"eslint"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^8.57.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"eslint-plugin-react"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^7.34.1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"eslint-plugin-react-hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^4.6.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"eslint-plugin-react-refresh"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^0.4.6"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"vite"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^5.2.0"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&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 see my proposed and finalized GLC component types in their final form on &lt;strong&gt;&lt;em&gt;&lt;a href="https://github.com/ErikHarutyunyan/generate-react-component" rel="noopener noreferrer"&gt;my GitHub&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;, where not only are layouts and pages added, but there is also a template for quickly creating a redux store.&lt;/p&gt;







&lt;h2&gt;
  
  
  Benefits of Using Generate React CLI
&lt;/h2&gt;

&lt;p&gt;While we have already discussed the basics of using Generate React CLI, let's dive deeper into its benefits and how it can transform your development process.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Increased Productivity
&lt;/h3&gt;

&lt;p&gt;As mentioned earlier, manually creating React components can be a tedious and time-consuming task. With Generate React CLI, you can automate this process and save yourself hours of repetitive work. This allows you to focus on more critical aspects of your project, ultimately increasing your productivity.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Consistency in Code
&lt;/h3&gt;

&lt;p&gt;Consistency is crucial in software development, especially when working with teams. With the Generate React CLI, all components are created using the same set of defaults, ensuring consistency throughout your codebase. This avoids any confusion or discrepancies in the code and makes it easier for team members to work together seamlessly.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Customizability
&lt;/h3&gt;

&lt;p&gt;The ability to create custom templates and add them to Generate React CLI allows you to tailor the tool according to your specific project needs. This not only enhances its functionality but also makes it more versatile and suitable for a wide range of projects.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Time-Saving
&lt;/h3&gt;

&lt;p&gt;With Generate React CLI, creating components is just a matter of executing a few simple commands. This not only saves time but also reduces the chances of errors that may occur while manually creating components. This feature is particularly useful when working on tight deadlines or complex projects.&lt;/p&gt;




&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;Automating the process of generating React components can save a lot of time and improve productivity. With Generate React CLI, you can automate this process and customize it to suit your project's needs. Whether you are a novice or an experienced React developer, mastering component generation can make your work easier and more enjoyable.&lt;/p&gt;

&lt;p&gt;Remember, being a successful software engineer is not just about writing code. It's also about finding ways to work smarter and making the most of the tools available to you.&lt;/p&gt;




&lt;p&gt;I have tried to explain the practices with the best example that I know. If you know others, share in the comments for everyone!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Thanks For Reading, Follow Me For More&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>nextjs</category>
      <category>webdev</category>
    </item>
    <item>
      <title>The Ultimate Guide to Node.js Version Managers: NVM, NVS, fnm, Volta, and asdf | Part 3</title>
      <dc:creator>Erik Harutyunyan</dc:creator>
      <pubDate>Thu, 12 Sep 2024 12:27:39 +0000</pubDate>
      <link>https://forem.com/01erik33/the-ultimate-guide-to-nodejs-version-managers-nvm-nvs-fnm-volta-and-asdf-part-3-3gnh</link>
      <guid>https://forem.com/01erik33/the-ultimate-guide-to-nodejs-version-managers-nvm-nvs-fnm-volta-and-asdf-part-3-3gnh</guid>
      <description>&lt;h3&gt;
  
  
  asdf
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;asdf&lt;/code&gt; is a version manager that aims to be a “universal language version manager.” Created by Jean-Louis Reynaud in 2015, it supports a wide variety of programming languages and tools, including Node.js. It is designed to be easily extendable as new languages and tools are introduced.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;asdf&lt;/code&gt; currently supports Node.js, Ruby, Python, Elixir, Java, Rust, PHP, Perl, Haskell, R, Lua, and Erlang. For all of these languages, you can manage different versions in one place via a single &lt;code&gt;.tool-versions&lt;/code&gt; configuration file. This file can be included in your project repository so that the entire team uses the same versions of the tools.&lt;/p&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%2F9978o5sarh5l1ucjckti.webp" 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%2F9978o5sarh5l1ucjckti.webp" alt="asdf info" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Install and Use
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Dependencies required for &lt;code&gt;asdf&lt;/code&gt;:
&lt;/h4&gt;

&lt;p&gt;First, we need to install some dependencies like &lt;code&gt;coreutils&lt;/code&gt;, &lt;code&gt;curl&lt;/code&gt;, and &lt;code&gt;git&lt;/code&gt;. These dependencies are used by &lt;code&gt;asdf&lt;/code&gt; to manage different language versions.&lt;/p&gt;

&lt;h4&gt;
  
  
  macOS:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Homebrew:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;coreutils curl git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Spack:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;spack &lt;span class="nb"&gt;install &lt;/span&gt;coreutils curl git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Linux:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;curl git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Installationon macOS and Linux:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Installation via Git&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;Open the terminal and run 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;git clone https://github.com/asdf-vm/asdf.git ~/.asdf &lt;span class="nt"&gt;--branch&lt;/span&gt; v0.13.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Or install via Homebrew (only for macOS):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Shell Configuration:&lt;/strong&gt; Add the following lines to your shell configuration file (e.g., &lt;code&gt;~/.bashrc&lt;/code&gt; or &lt;code&gt;~/.zshrc&lt;/code&gt;):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Bash/Zsh:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;. $HOME/.asdf/asdf.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;. $HOME/.asdf/completions/asdf.bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then apply the changes with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;source `~/.bashrc`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;source `~/.zshrc`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Installation&lt;/strong&gt; &lt;strong&gt;for Windows:&lt;/strong&gt;&lt;br&gt;
To install asdf on Windows, use the Windows Subsystem for Linux (WSL):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Set up WSL:&lt;/strong&gt; Install and set up WSL on your system using the Microsoft guide.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Install asdf in WSL:&lt;/strong&gt; Follow the installation instructions for asdf for Linux, as described above.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;After setting up asdf in your shell configuration, plugins are installed to manage specific tools. When a tool is installed, shims (proxy files) are created, which intercept calls to executables, determine the tool version from &lt;code&gt;.tool-versions&lt;/code&gt;, and execute the corresponding version.&lt;/p&gt;
&lt;h3&gt;
  
  
  Using asdf:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  List all available plugins: &lt;code&gt;asdf plugin list all&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  Add a plugin: &lt;code&gt;asdf plugin add nodejs&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  List installed plugins: &lt;code&gt;asdf plugin list&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  Remove a plugin: &lt;code&gt;asdf plugin remove nodejs&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  Update a plugin: &lt;code&gt;asdf plugin update nodejs&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  Update all plugins: &lt;code&gt;asdf plugin update --all&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  Install a specific version or starting with a certain number of Node.js: &lt;code&gt;asdf install nodejs 16.13.0&lt;/code&gt; or &lt;code&gt;asdf install nodejs latest:18&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  Install the latest available version: &lt;code&gt;asdf install nodejs latest&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  Set the global version (default): &lt;code&gt;asdf global nodejs 16.13.0&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  Set the version for the current project: &lt;code&gt;asdf local nodejs 16.13.0&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  Remove a version of Node.js: &lt;code&gt;asdf uninstall nodejs 16.13.0&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  View installed versions of Node.js: &lt;code&gt;asdf list nodejs&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  View all available Node.js versions: &lt;code&gt;asdf list all nodejs&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  Install versions from the &lt;code&gt;.tool-versions&lt;/code&gt; file: &lt;code&gt;asdf install&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  Show the current active version of Node.js: &lt;code&gt;asdf current nodejs&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;.tool-versions Configuration File:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;What it is:&lt;/strong&gt; &lt;code&gt;.tool-versions&lt;/code&gt; is a text file in the project's root directory that defines the versions of all tools used in the project.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Why it’s needed:&lt;/strong&gt; Ensures that all team members use the same tool versions, simplifies environment setup, and prevents version conflicts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example content of the&lt;/strong&gt; &lt;code&gt;**.tool-versions**&lt;/code&gt; &lt;strong&gt;file:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nodejs 16.13.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Advantages of asdf:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Versatility:&lt;/strong&gt; Manage versions of various languages and tools with a single manager (one CLI).&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Uniform commands:&lt;/strong&gt; Using the same commands for all tools simplifies work and reduces the need to learn different commands.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Single configuration file:&lt;/strong&gt; All tool versions for a project are specified in a single &lt;code&gt;.tool-versions&lt;/code&gt; file, simplifying collaboration and preventing version conflicts.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Ease of migration:&lt;/strong&gt; Supports existing configuration files like &lt;code&gt;.nvmrc&lt;/code&gt;, &lt;code&gt;.node-version&lt;/code&gt;, &lt;code&gt;.ruby-version&lt;/code&gt;, making it easier to transition from other version managers.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Automatic version switching:&lt;/strong&gt; asdf automatically switches tool versions based on the current directory.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Extensibility through plugins:&lt;/strong&gt; Ability to add support for new languages and tools through plugins.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Autocompletion for shells:&lt;/strong&gt; Supports autocompletion for popular shells (Bash, Zsh, Fish, Elvish).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Disadvantages of asdf:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Limited dependency support:&lt;/strong&gt; Does not manage system package dependencies; requires manual installation.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Complex setup for beginners:&lt;/strong&gt; Can be difficult to set up and integrate with the shell for beginners.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Low performance in some cases:&lt;/strong&gt; Using shims can sometimes be slower than directly running tools.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Not suitable for all scenarios:&lt;/strong&gt; Not always optimal for system tools or specific scenarios.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Less popular:&lt;/strong&gt; Less known than specialized version managers, which can make it harder to find documentation and support.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Another tool quite similar to asdf is &lt;a href="https://vfox.lhan.me/" rel="noopener noreferrer"&gt;vfox&lt;/a&gt;. It supports version management for various programming languages. It also has an MSI installer, unlike asdf, and hence is painless to install for the majority of Windows users. In fact, the function is quite similar to asdf in that it supports Node.js versions by simply changing a configuration.&lt;/p&gt;
&lt;/blockquote&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%2F1xb4msssn9jc5lv4scjj.png" class="article-body-image-wrapper"&gt;&lt;img alt="sdk + plugin" 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%2F1xb4msssn9jc5lv4scjj.png" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Comparing Node.js Version Management Tools
&lt;/h2&gt;

&lt;p&gt;Selection of a tool that manages the version of Node.js requires considering every factor affecting performance, speed, and usability. Given below is a detailed comparison of key tools based on several factors:&lt;/p&gt;

&lt;h2&gt;
  
  
  Performance and Speed:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;NVM&lt;/strong&gt;: A reliable and flexible tool, but it can be slower when frequently switching versions due to using shell scripts. Suitable for most developers, especially if delays are not critical.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NVS&lt;/strong&gt;: Provides good performance for managing Node.js versions in cross-platform environments. Its speed may be lower than tools written in faster languages, but it effectively handles the task and supports automatic version switching.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;fnm&lt;/strong&gt;: One of the fastest tools due to its Rust implementation. Provides instant version switching, making it ideal for large projects and developers who frequently change Node.js versions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Volta&lt;/strong&gt;: Automatically manages versions, saving time on setup and switching. An ideal choice for teams where automation and version consistency are important.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;asdf&lt;/strong&gt;: A universal tool for managing versions of many programming languages and tools. Suitable for multi-language projects, but may be slower and harder to set up for working only with Node.js.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Ease of Use:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;NVM&lt;/strong&gt;: Intuitive and easy to use, especially for beginners. Supports most operating systems and provides many useful commands for version management.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NVS&lt;/strong&gt;: Convenient for experienced users thanks to support for automatic version switching and an interactive menu. However, beginners may need time to master the commands.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;fnm&lt;/strong&gt;: Provides high performance and is convenient for frequent version switching. Suitable for those who value speed and minimal response time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Volta&lt;/strong&gt;: Maximally simplifies version management through automation, reducing the likelihood of errors and saving time. Ideal for teamwork and process automation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;asdf&lt;/strong&gt;: Suitable for developers working with multiple programming languages. Allows managing versions of different environments and tools through a single interface but requires more time to set up.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Version management of Node.js is one of the most common tasks that almost every developer does, whether it is supporting numerous projects or testing new features. Each tool here has its own advantages and disadvantages, so the decision about which tool to use will depend upon project and team needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Recommendations
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;NVM&lt;/strong&gt;: Ideal for beginners and those looking for simplicity and flexibility. Provides convenient Node.js version management with a wide range of features.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NVS&lt;/strong&gt;: Suitable for developers who need flexible Node.js version management in different environments. It is a good choice for working with multiple versions or forks, although it is not as fast as some alternatives.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;fnm&lt;/strong&gt;: Recommended for developers who value speed and performance. Due to its Rust implementation, fnm provides fast version switching. Suitable for those who frequently switch versions and work in a cross-platform environment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Volta&lt;/strong&gt;: Suitable for those who value automation and teamwork. This tool automatically manages Node.js versions for each project, saving time and reducing the risk of errors. Ideal for teams working on large projects where version consistency is important.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;asdf&lt;/strong&gt;: The best choice for developers working on multi-language projects. Its versatility and support for multiple languages make it convenient for diverse tasks. Suitable for those working with different programming languages and tools but requires a bit more time to set up.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No matter which of them to use, version management with Node.js is just such an important part of modern development that allows one to keep their applications stable and secure, with their performance optimized. Choose the tool that best fits your needs and your style.&lt;/p&gt;

&lt;p&gt;The choice is yours! Depending on how you organize your work, each of these tools can become your faithful helper in managing Node.js versions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Links to Additional Resources and Documentation
&lt;/h2&gt;

&lt;p&gt;You can learn more about and decide on a Node.js version manager by following the official documentation and resources listed below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/bernardoduarte/awesome-version-managers?tab=readme-ov-file#nodejs" rel="noopener noreferrer"&gt;Awesome Version Managers&lt;/a&gt; — a curated list of popular version management tools with helpful links and additional information.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/nvm-sh/nvm" rel="noopener noreferrer"&gt;Official NVM Documentation&lt;/a&gt; — a complete guide to installing and using NVM.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/jasongin/nvs" rel="noopener noreferrer"&gt;Official NVS Documentation&lt;/a&gt; — instructions for installing, configuring, and using NVS.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://fnm.vercel.app" rel="noopener noreferrer"&gt;Official fnm Documentation&lt;/a&gt; — a guide for installing and applying fnm.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.volta.sh" rel="noopener noreferrer"&gt;Official Volta Documentation&lt;/a&gt; — information about installing and using Volta.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://asdf-vm.com" rel="noopener noreferrer"&gt;Official asdf Documentation&lt;/a&gt; — a comprehensive guide to installing, configuring, and using asdf.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These resources will give you a much better understanding of what each tool can do and help you select the right version management method.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;a href="https://dev.to/01erik33/the-ultimate-guide-to-nodejs-version-managers-nvm-nvs-fnm-volta-and-asdf-part-2-4c6n"&gt;Prev to Part 2&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>node</category>
      <category>tutorial</category>
      <category>javascript</category>
      <category>tooling</category>
    </item>
    <item>
      <title>The Ultimate Guide to Node.js Version Managers: NVM, NVS, fnm, Volta, and asdf | Part 2</title>
      <dc:creator>Erik Harutyunyan</dc:creator>
      <pubDate>Thu, 12 Sep 2024 12:00:03 +0000</pubDate>
      <link>https://forem.com/01erik33/the-ultimate-guide-to-nodejs-version-managers-nvm-nvs-fnm-volta-and-asdf-part-2-4c6n</link>
      <guid>https://forem.com/01erik33/the-ultimate-guide-to-nodejs-version-managers-nvm-nvs-fnm-volta-and-asdf-part-2-4c6n</guid>
      <description>&lt;h3&gt;
  
  
  NVS (Node Version Switcher)
&lt;/h3&gt;

&lt;p&gt;NVS is a handy, cross-platform utility for managing Node.js versions and their forks. It's written in JavaScript.&lt;/p&gt;

&lt;h4&gt;
  
  
  How to Install and Use
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Installation on macOS and Linux:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Setting the installation path:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;NVS_HOME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/.nvs"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Clone the repository and install:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/jasongin/nvs &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$NVS_HOME&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$NVS_HOME&lt;/span&gt;&lt;span class="s2"&gt;/nvs.sh"&lt;/span&gt; &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This adds NVS into the shell, making it ready for use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installation for Windows:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can install using the MSI installer from &lt;a href="https://github.com/jasongin/nvs/releases" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;You can also install via the winget command:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;winget &lt;span class="nb"&gt;install &lt;/span&gt;jasongin.nvs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Or with Chocolatey:
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Using NVS:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Install the latest or LTS version of Node.js:** &lt;code&gt;nvs add latest&lt;/code&gt; or &lt;code&gt;nvs add lts&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Install a specific version: &lt;code&gt;nvs add 14.17.0&lt;/code&gt; or &lt;code&gt;nvs add 14&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Remove versions: &lt;code&gt;nvs rm 14.17.0&lt;/code&gt; or &lt;code&gt;nvs rm 14&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;View installed versions: &lt;code&gt;nvs ls&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;View available versions for installation: &lt;code&gt;nvs ls-remote&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Switch to a specific Node.js version: &lt;code&gt;nvs use 14&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Set the default version: &lt;code&gt;nvs link 20&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Remove the default version link: &lt;code&gt;nvs unlink 20&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Enable automatic version switching based on the directory:** &lt;code&gt;nvs auto on&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This command enables NVS to automatically switch Node.js versions when entering directories containing &lt;code&gt;.node-version&lt;/code&gt; or &lt;code&gt;.nvmrc&lt;/code&gt; files.&lt;/p&gt;

&lt;h3&gt;
  
  
  Interactive NVS Menu:
&lt;/h3&gt;

&lt;p&gt;When executed without parameters, NVS opens an interactive menu for switching and downloading Node.js versions.&lt;/p&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%2F2q8umdsxgwnmmblm83ct.gif" 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%2F2q8umdsxgwnmmblm83ct.gif" alt=" " width="450" height="276"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Advantages of NVS:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cross-platform:&lt;/strong&gt; Works on Windows, macOS, and Linux.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ease of use:&lt;/strong&gt; Interactive menu for quick version management.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automatic switching:&lt;/strong&gt; Automatically selects the Node.js version based on the current directory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flexibility:&lt;/strong&gt; Supports multiple remote sources and version aliases.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CI Support:&lt;/strong&gt; Integration with CI environments like AppVeyor and Travis CI.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Disadvantages of NVS:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Node.js dependency:&lt;/strong&gt; Requires Node.js to be installed to work.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Limited support in Windows Command Prompt:&lt;/strong&gt; Automatic version switching is only supported in PowerShell and Bash.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lower popularity:&lt;/strong&gt; Smaller community and fewer resources for support compared to more well-known tools.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Limited interaction with system package managers:&lt;/strong&gt; NVS does not integrate with system package managers like APT or Homebrew, which may limit its use in corporate or specialized environments.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  fnm (Fast Node Manager)
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;fnm&lt;/code&gt; is one of the newest tools for managing Node.js versions, supporting caching and multithreading, making it significantly faster and more efficient. Written in Rust, &lt;code&gt;fnm&lt;/code&gt; provides fast switching between Node.js versions and supports most operating systems.&lt;/p&gt;

&lt;h4&gt;
  
  
  How to Install and Use
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Installation on macOS and Linux:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Script:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Homebrew:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Installation for Windows:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Winget:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;winget &lt;span class="nb"&gt;install &lt;/span&gt;Schniz.fnm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Scoop:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Chocolatey:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Shell Configuration:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bash:&lt;/strong&gt; Add to the &lt;code&gt;.bashrc&lt;/code&gt; file:
&lt;/li&gt;
&lt;/ul&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="nt"&gt;--shell&lt;/span&gt; bash&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;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bash:&lt;/strong&gt; Add to the &lt;code&gt;.bashrc&lt;/code&gt; file:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;winget &lt;span class="nb"&gt;install &lt;/span&gt;Schniz.fnm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Zsh:&lt;/strong&gt; Add to the&lt;code&gt;.zshrc&lt;/code&gt; file:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;winget &lt;span class="nb"&gt;install &lt;/span&gt;Schniz.fnm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fish shell:&lt;/strong&gt; Create &lt;code&gt;~/.config/fish/conf.d/fnm.fish&lt;/code&gt; and add:
&lt;/li&gt;
&lt;/ul&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; fish | &lt;span class="nb"&gt;source&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;PowerShell:&lt;/strong&gt; To edit the profile in PowerShell, run::
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;p&gt;Add the following line at the bottom of the profile file:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Using NVS:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Install the latest Node.js version: &lt;code&gt;fnm install latest&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  Show the current active version: &lt;code&gt;fnm current&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  Install a specific version: &lt;code&gt;fnm install 14.17.0&lt;/code&gt; or &lt;code&gt;fnm install 18&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  Remove versions: &lt;code&gt;fnm uninstall 14.17.0&lt;/code&gt; or &lt;code&gt;fnm uninstall 18&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  View installed versions: &lt;code&gt;fnm ls&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  View available versions for installation: &lt;code&gt;fnm ls-remote&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  Switch versions: &lt;code&gt;fnm use 16.13.0&lt;/code&gt; or &lt;code&gt;fnm use 20&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  Set the default version: &lt;code&gt;fnm default 20&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  Automatic version switching based on specifications in &lt;code&gt;.nvmrc&lt;/code&gt; or &lt;code&gt;.node-version&lt;/code&gt; files: &lt;code&gt;fnm use&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Advantages of fnm:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;High speed:&lt;/strong&gt; Fast version switching due to Rust implementation.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Cross-platform:&lt;/strong&gt; Supports most operating systems.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Minimal dependencies:&lt;/strong&gt; fnm does not require many dependencies and works quickly even on old or low-powered machines.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Disadvantages of fnm:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Limited documentation:&lt;/strong&gt; As a new tool, fnm has less documentation and resources for new users, which can make it harder to learn.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Less community support:&lt;/strong&gt; fnm has fewer users, which can make it harder to find solutions to problems.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Volta
&lt;/h3&gt;

&lt;p&gt;Volta is a brand new version manager for Node.js, based on Rust. It makes installing and managing Node.js-easier among other tools. It was created by Kevin Sawicki in 2019 and is still actively maintained. Volta works a little bit different from NVM; instead of keeping track of multiple Node.js versions, it maintains projects and their dependencies but supports other tools like npm and Yarn.&lt;/p&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%2Fu63jlqezsi6wqzxpe202.jpg" 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%2Fu63jlqezsi6wqzxpe202.jpg" alt=" " width="800" height="355"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  How to Install and Use
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Installation on macOS and Linux:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl https://get.volta.sh | bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By default, the script will run and it will automatically update your shell's configuration file. If you don't want that, you can configure the shell yourself:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Set the VOLTA_HOME variable to &lt;code&gt;$HOME/.volta&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  Add &lt;code&gt;$VOLTA_HOME/bin&lt;/code&gt; to the beginning of the PATH variable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Installation for Windows։&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Install Volta using Winget:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;winget install Volta.Volta
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively, you may download an installer and perform a manual installation from &lt;a href="https://github.com/volta-cli/volta/releases" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using Volta:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Install a specific Node.js version: &lt;code&gt;volta install node@16.13.0&lt;/code&gt; or &lt;code&gt;volta install node@22&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  Install the latest available or LTS version of Node.js: &lt;code&gt;volta install node@latest&lt;/code&gt; or &lt;code&gt;volta install node&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  Set the default version: &lt;code&gt;volta install node@16&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  Show the current active Node.js version: &lt;code&gt;volta which node&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  View installed tool versions: &lt;code&gt;volta list all&lt;/code&gt; or &lt;code&gt;volta list node&lt;/code&gt; for Node.js, &lt;code&gt;volta list yarn&lt;/code&gt; for Yarn&lt;/li&gt;
&lt;li&gt;  Remove a Node.js version: &lt;code&gt;volta uninstall node@16.13.0&lt;/code&gt; or &lt;code&gt;volta uninstall node@22&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  Update a tool to the latest version: &lt;code&gt;volta install &amp;lt;tool&amp;gt;@latest&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  Pin a version for the project: &lt;code&gt;volta pin node@20.16&lt;/code&gt; or &lt;code&gt;volta pin yarn@1.19&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example pinning in&lt;/strong&gt; &lt;code&gt;package.json**&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"volta"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"node"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"20.16.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"yarn"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1.19.2"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Advantages of Volta:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Automatic version management:&lt;/strong&gt; Selects the required tool versions for each project.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;High speed:&lt;/strong&gt; Quickly installs and switches versions due to local caching.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Unified environment:&lt;/strong&gt; All project participants use the same tool versions.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Avoids conflicts:&lt;/strong&gt; Global packages are isolated, preventing dependency issues.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Convenience:&lt;/strong&gt; Automatically locks tool versions for each project, simplifying dependency management and teamwork in CI/CD.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Security:&lt;/strong&gt; Ensures that changes in one project do not affect others.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Versatility:&lt;/strong&gt; Supports installing and managing not only Node.js but also tools like npm, Yarn, and even TypeScript, making it a versatile solution for JavaScript developers.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Cross-platform:&lt;/strong&gt; Supports Windows, macOS, and Linux.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Disadvantages of Volta:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Only supports the Node.js ecosystem:&lt;/strong&gt; Works only with Node.js, npm, Yarn, and JavaScript tools. This limits its use for developers working with other programming languages.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Smaller community and support:&lt;/strong&gt; Less documentation and support compared to NVM or fnm.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Limited configuration flexibility:&lt;/strong&gt; Fewer options for detailed environment configuration.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Not all features work the same across platforms:&lt;/strong&gt; Some features may have limitations or work differently on Windows compared to Unix platforms, causing unpredictable behavior.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Dependency on&lt;/strong&gt; &lt;code&gt;package.json&lt;/code&gt; configuration: For Volta to work correctly, it requires precise settings in &lt;code&gt;package.json&lt;/code&gt;, adding a dependency on the proper filling of this file.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://dev.to/01erik33/the-ultimate-guide-to-nodejs-version-managers-nvm-nvs-fnm-volta-and-asdf-part-1-52em"&gt;&lt;em&gt;&lt;strong&gt;Prev to Part 1&lt;/strong&gt;&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/01erik33/the-ultimate-guide-to-nodejs-version-managers-nvm-nvs-fnm-volta-and-asdf-part-3-3gnh"&gt;&lt;em&gt;&lt;strong&gt;Next to Part 3&lt;/strong&gt;&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>node</category>
      <category>volta</category>
      <category>asdf</category>
      <category>nvs</category>
    </item>
    <item>
      <title>The Ultimate Guide to Node.js Version Managers: NVM, NVS, fnm, Volta, and asdf | Part 1</title>
      <dc:creator>Erik Harutyunyan</dc:creator>
      <pubDate>Thu, 12 Sep 2024 10:28:30 +0000</pubDate>
      <link>https://forem.com/01erik33/the-ultimate-guide-to-nodejs-version-managers-nvm-nvs-fnm-volta-and-asdf-part-1-52em</link>
      <guid>https://forem.com/01erik33/the-ultimate-guide-to-nodejs-version-managers-nvm-nvs-fnm-volta-and-asdf-part-1-52em</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Hey! If you ever developed with Node.js, you understand that quite often for projects, there’s a need to use different versions. Probably one project would work on version 10, another on version 14, and a new one requires the latest, say 20. Along with new features on each new release, a set of new challenges emerge. These are compatibility with libraries and frameworks, tests of new functionality, and stability for existing projects.&lt;/p&gt;

&lt;p&gt;I faced this problem myself when I was working on several projects at one time. What seemed to be a very simple task — installation of Node.js — turned into chaos when each project required its version. In this article, I will tell you how I solved this problem using Node.js version management tools like NVM, NVS, fnm, Volta, and asdf. I’ll be describing how they work, listing pros and cons, and giving you my personal experience in order to help you choose the best node version manager for your needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why is Version Management Important for Developers?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Compatibility with Libraries and Frameworks
&lt;/h3&gt;

&lt;p&gt;Node.js itself is rapidly developing, and so is its tooling ecosystem. New libraries, frameworks, and versions require a great deal of flexibility in using different Node.js versions. Some view frameworks may only be compatible with particular Node.js LTS versions that one would have to switch to according to the project being developed. Switching between different Node.js versions will help avoid compatibility problems and keep the code running smoothly.&lt;/p&gt;

&lt;p&gt;Consider that you work on some old project, which depends on a specific version of the library. You at the same time run some new project depending on the latest version of Node.js since it uses the features available only within the recent version. New versions of Node.js may include functions incompatible with versions of these libraries, and that will lead to application performance errors or instability.&lt;/p&gt;

&lt;p&gt;One day, I got into such a predicament where I needed to install different versions of Node.js manually, work with that, then reinstall another version, and so on and so forth. Believe me, that was a nightmare. And then, it dawned on my mind that without a node version manager utility tool, I couldn’t do anything.&lt;/p&gt;

&lt;h3&gt;
  
  
  New Feature Testing
&lt;/h3&gt;

&lt;p&gt;Software development is all about continuous testing and implementation of new features. Each new version of Node.js exposes developers to additional language and platform capabilities, such as enhanced asynchronous programming support, improvements in the module system, and new APIs. Such features would then be tested on real projects to ascertain how effective they were and whether to implement them into the main application.&lt;/p&gt;

&lt;p&gt;But what if your current project is running stable under an older version of Node.js, and this might get broken after upgrading Node.js?&lt;/p&gt;

&lt;p&gt;That often meant checking new features in the master branch, or a copy of the project using the new Node.js version. Luckily, tooling for version management allowed me to switch between different versions with no brokenness in the master branch.&lt;/p&gt;

&lt;h3&gt;
  
  
  Ensuring Stability and Security
&lt;/h3&gt;

&lt;p&gt;Stability and security are the major factors for any project. In older versions of Node.js, some bugs may be held, which get fixed with new releases. Upgrading to a recent version is pretty risky if an application depends on the older libraries that support new platform version upgrades.&lt;/p&gt;

&lt;p&gt;Versioning Node.js allows you to safely upgrade the platform version while retaining the possibility to roll back in the case of problems, thus helping developers to keep their application stable and safe from vulnerabilities.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ways to Manage Node.js Versions
&lt;/h2&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%2Ftelpspy6lvynhqlv0139.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%2Ftelpspy6lvynhqlv0139.png" alt=" " width="800" height="1106"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Standard Installation
&lt;/h3&gt;

&lt;p&gt;If you are a newcomer to Node.js, you’ve probably downloaded it from its official website and installed it. That is the most straightforward way that is great when you need only one version of Node.js. You download the installer, follow the instructions, and voilà — Node.js is on your computer.&lt;/p&gt;

&lt;p&gt;But imagine that you work with several projects and all of them require some specific versions of Node.js. For example, you have some old project on Node.js 10 and some new one on Node.js 20. Constant reinstalling of Node.js is too time-consuming and just inconvenient.&lt;/p&gt;

&lt;h3&gt;
  
  
  Node.js Version Management Tools
&lt;/h3&gt;

&lt;p&gt;There are plenty of tools for managing Node.js versions. In this article, I’m going to discuss five popular options: NVM (Node Version Manager), NVS (Node Version Switcher), fnm, or Fast Node Manager, Volta, and asdf. All of these come with their ways and features to manage the versions, which might be applicable for various tasks and teams.&lt;/p&gt;

&lt;p&gt;Those version managers will automate the management process, manage the consistency of the versions, and avoid compatibility issues, helping you choose the right tool for your needs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Integration with CI/CD Tools
&lt;/h3&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%2Fcgoqas0guuougrwwf90t.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%2Fcgoqas0guuougrwwf90t.png" alt=" " width="318" height="159"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you start working in a team, version management becomes way more important. Each developer might own their version of Node.js, which may get very problematic at different development and deployment stages as different bugs could arise. In large projects and teams where automation plays a huge role, such Node.js version management tools can be integrated into the CI/CD processes.&lt;/p&gt;

&lt;p&gt;Tools like NVM can be integrated into CI/CD processes, allowing each build to use the required version of Node.js without manual intervention, ensuring that every team member uses the correct Node.js version for their tasks. This helps maintain stability and consistency across different environments, such as development environment, testing, and production.&lt;/p&gt;

&lt;h2&gt;
  
  
  Overview of Node.js Version Management Tools
&lt;/h2&gt;

&lt;p&gt;Now, the different tools managing different Node.js versions have their pros and cons, and I’ll try to explain what situation each tool fits best.&lt;/p&gt;

&lt;h3&gt;
  
  
  NVM (Node Version Manager)
&lt;/h3&gt;

&lt;p&gt;NVM is short for Node Version Manager. It is one of the oldest and still very popular managers of Node.js versions. NVM was created by Tim Caswell in 2010 and is still actively maintained.&lt;/p&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%2Fbs8iuxz3vgtryinfcba4.jpg" 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%2Fbs8iuxz3vgtryinfcba4.jpg" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;NVM downloads each Node.js version into its own, self-contained directory at &lt;code&gt;~/.nvm/versions/node/&lt;/code&gt;. When you’re switching between versions by using &lt;code&gt;nvm use&lt;/code&gt;, it updates your &lt;code&gt;$PATH&lt;/code&gt; environment variable to point to the appropriate directory.&lt;/p&gt;

&lt;h4&gt;
  
  
  How to Install and Use
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Installation on macOS and Linux&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;To install NVM on macOS and Linux, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open the terminal and enter the following:
&lt;/li&gt;
&lt;/ol&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; https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wget &lt;span class="nt"&gt;-qO-&lt;/span&gt; https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will download and run the install script for NVM from the official NVM GitHub repository, and the NVM will be installed on your system. Once it has been installed you can verify that NVM has been installed using the command:&lt;br&gt;
&lt;code&gt;nvm — version&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If everything went smoothly, you should see the NVM version.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installation for Windows&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Download the &lt;code&gt;nvm-windows&lt;/code&gt; installer from its &lt;a href="https://github.com/coreybutler/nvm-windows/releases" rel="noopener noreferrer"&gt;GitHub repository&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Run the installer and follow the on-screen instructions, making sure to choose the correct installation path.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;During the installation process, it will automatically set up NVM configurations in your profile. If you are using &lt;code&gt;zsh&lt;/code&gt;, that would be &lt;code&gt;~/.zshrc&lt;/code&gt;; or if you’re using bash, that would be &lt;code&gt;~/.bashrc&lt;/code&gt;, &lt;code&gt;~/.bash_profile&lt;/code&gt;, or some other profile.&lt;/p&gt;

&lt;p&gt;If that does not happen automatically, add the NVM configuration to the profile file yourself:&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;export &lt;/span&gt;&lt;span class="nv"&gt;NVM_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;XDG_CONFIG_HOME&lt;/span&gt;&lt;span class="p"&gt;-&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;printf&lt;/span&gt; %s &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;HOME&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/.nvm"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;printf&lt;/span&gt; %s &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;XDG_CONFIG_HOME&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/nvm"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$NVM_DIR&lt;/span&gt;&lt;span class="s2"&gt;/nvm.sh"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="se"&gt;\.&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$NVM_DIR&lt;/span&gt;&lt;span class="s2"&gt;/nvm.sh"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Using NVM:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;List available Node.js versions: &lt;code&gt;nvm ls-remote&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Install the latest Node.js version: &lt;code&gt;nvm install node&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Install a specific version: &lt;code&gt;nvm install 14.17.0&lt;/code&gt; or &lt;code&gt;nvm install 14&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Switch between versions: &lt;code&gt;nvm use 14.17.0&lt;/code&gt; or &lt;code&gt;nvm use 14&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Set default version: &lt;code&gt;nvm alias default 18&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;View installed versions: &lt;code&gt;nvm ls&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Version from &lt;code&gt;.nvmrc&lt;/code&gt;: If your project directory contains a &lt;code&gt;.nvmrc&lt;/code&gt; file specifying the Node.js version required—e.g., 16.13.0 or 20—you can automatically switch to that version with &lt;code&gt;nvm use&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Advantages of NVM:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Installation and Usage:&lt;/strong&gt; Done within a few minutes, and thereafter, it's quite easy to handle various Node.js versions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flexibility:&lt;/strong&gt; It allows one to run or install many Node.js versions on one device without conflicts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compatibility:&lt;/strong&gt; NVM works on most Unix-like systems and runs on macOS or Linux. For Windows, there's a port called &lt;code&gt;nvm-windows&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Support for &lt;code&gt;.nvmrc&lt;/code&gt; files:&lt;/strong&gt; This file allows you to automatically switch to the desired Node.js version when entering a project directory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Community and documentation:&lt;/strong&gt; A substantial user base with good documentation makes NVM a trustworthy choice.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Disadvantages of NVM:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Performance:&lt;/strong&gt; Sometimes, NVM can be slower than other tools, especially when frequently switching between versions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Manual management:&lt;/strong&gt; For some developers, manually switching versions may seem inconvenient, especially if automation is required.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inconvenience on Windows:&lt;/strong&gt; If you are working on Windows, using NVM through WSL can be inconvenient.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;&lt;a href="https://dev.to/01erik33/the-ultimate-guide-to-nodejs-version-managers-nvm-nvs-fnm-volta-and-asdf-part-2-4c6n"&gt;Next to Part 2&lt;/a&gt;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>node</category>
      <category>versionmanagment</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
