<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: lucky chauhan</title>
    <description>The latest articles on DEV Community by lucky chauhan (@luckychauhan).</description>
    <link>https://dev.to/luckychauhan</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%2F1810327%2F7f68cd2b-91d6-4cff-a587-5c97aeb35df2.jpg</url>
      <title>DEV Community: lucky chauhan</title>
      <link>https://dev.to/luckychauhan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/luckychauhan"/>
    <language>en</language>
    <item>
      <title>How to Start a React Native Project and Build Your First “Hello World” App</title>
      <dc:creator>lucky chauhan</dc:creator>
      <pubDate>Fri, 26 Dec 2025 14:43:06 +0000</pubDate>
      <link>https://dev.to/luckychauhan/how-to-start-a-react-native-project-and-build-your-first-hello-world-app-4bhe</link>
      <guid>https://dev.to/luckychauhan/how-to-start-a-react-native-project-and-build-your-first-hello-world-app-4bhe</guid>
      <description>&lt;p&gt;Below is a &lt;strong&gt;complete, production-ready article&lt;/strong&gt; you can publish directly.&lt;br&gt;
It covers &lt;strong&gt;environment setup → project creation → running → Hello World → common errors&lt;/strong&gt; in a clean, structured way.&lt;/p&gt;


&lt;h1&gt;
  
  
  How to Start a React Native Project and Build Your First “Hello World” App
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;React Native&lt;/strong&gt; allows you to build &lt;strong&gt;native Android and iOS apps&lt;/strong&gt; using &lt;strong&gt;JavaScript and React&lt;/strong&gt;. Instead of maintaining separate codebases for each platform, you write once and ship everywhere.&lt;/p&gt;

&lt;p&gt;This guide walks through &lt;strong&gt;everything from zero to your first running app&lt;/strong&gt;.&lt;/p&gt;


&lt;h2&gt;
  
  
  What You Will Build
&lt;/h2&gt;

&lt;p&gt;A simple React Native application that displays:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello World 🚀
Welcome to React Native
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Android Emulator or Physical Device&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before starting, ensure the following are installed:&lt;/p&gt;

&lt;h3&gt;
  
  
  Required Tools
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Node.js (LTS)&lt;/td&gt;
&lt;td&gt;JavaScript runtime&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;npm / yarn&lt;/td&gt;
&lt;td&gt;Package manager&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Java JDK (17 recommended)&lt;/td&gt;
&lt;td&gt;Android build system&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Android Studio&lt;/td&gt;
&lt;td&gt;Emulator + SDK&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Code Editor&lt;/td&gt;
&lt;td&gt;VS Code recommended&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  1. Install Android Studio
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Install &lt;strong&gt;Android SDK&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enable:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Android SDK Platform 33+&lt;/li&gt;
&lt;li&gt;Android SDK Build Tools&lt;/li&gt;
&lt;li&gt;Android Emulator&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Set Environment Variables (Windows)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ANDROID_HOME=C:\Users\&amp;lt;username&amp;gt;\AppData\Local\Android\Sdk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add to &lt;code&gt;PATH&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;%ANDROID_HOME%\platform-tools
%ANDROID_HOME%\emulator
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;






&lt;h2&gt;
  
  
  Two Ways to Start a React Native Project
&lt;/h2&gt;

&lt;p&gt;React Native supports &lt;strong&gt;two official approaches&lt;/strong&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Approach&lt;/th&gt;
&lt;th&gt;Use Case&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Expo (Recommended for beginners)&lt;/td&gt;
&lt;td&gt;Faster setup&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;React Native CLI&lt;/td&gt;
&lt;td&gt;Full native control&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This article uses &lt;strong&gt;React Native CLI&lt;/strong&gt; for real-world understanding.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 1: Create a New React Native Project
&lt;/h2&gt;

&lt;p&gt;Run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx react-native init HelloWorldApp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What this does:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Downloads React Native template&lt;/li&gt;
&lt;li&gt;Creates Android &amp;amp; iOS folders&lt;/li&gt;
&lt;li&gt;Installs dependencies&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Move into project:&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;cd &lt;/span&gt;HelloWorldApp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 2: Understand Project Structure
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HelloWorldApp/
 ├── android/        # Native Android code
 ├── ios/            # Native iOS code
 ├── node_modules/
 ├── App.js          # Main entry file
 ├── package.json
 └── index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Key file:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;App.js&lt;/code&gt; → main UI component&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Step 3: Start Android Emulator
&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%2F0e3fg4balej9be8lirzk.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%2F0e3fg4balej9be8lirzk.png" alt="Image" width="800" height="568"&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%2Fncjukxir501eqpi6iym3.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%2Fncjukxir501eqpi6iym3.png" alt="Image" width="800" height="564"&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%2Fipatojcxoei9bebrkxjr.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%2Fipatojcxoei9bebrkxjr.png" alt="Image" width="400" height="736"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Options:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Android Studio → AVD Manager → Start Emulator&lt;/li&gt;
&lt;li&gt;Or connect physical device with USB debugging&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Verify connection:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;adb devices
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 4: Run the App
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx react-native run-android
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Builds Android app&lt;/li&gt;
&lt;li&gt;Installs APK&lt;/li&gt;
&lt;li&gt;Launches emulator&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;First build may take &lt;strong&gt;2–5 minutes&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 5: Write Your First “Hello World”
&lt;/h2&gt;

&lt;p&gt;Open &lt;code&gt;App.js&lt;/code&gt; and replace content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;SafeAreaView&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;StyleSheet&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-native&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;SafeAreaView&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;styles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;container&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Text&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;styles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Hello&lt;/span&gt; &lt;span class="nx"&gt;World&lt;/span&gt; &lt;span class="err"&gt;🚀&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Text&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Text&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;styles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;subtitle&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Welcome&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="nx"&gt;Native&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Text&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/SafeAreaView&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;styles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;StyleSheet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;container&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;justifyContent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;center&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;alignItems&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;center&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#ffffff&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;fontSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;28&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;fontWeight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;700&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;subtitle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;fontSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;marginTop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#555&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save file → App reloads automatically.&lt;/p&gt;




&lt;h2&gt;
  
  
  Hot Reload Explained
&lt;/h2&gt;

&lt;p&gt;React Native uses &lt;strong&gt;Fast Refresh&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Save file&lt;/li&gt;
&lt;li&gt;UI updates instantly&lt;/li&gt;
&lt;li&gt;App state preserved&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No rebuild required.&lt;/p&gt;




&lt;h2&gt;
  
  
  Common Errors &amp;amp; Fixes
&lt;/h2&gt;

&lt;h3&gt;
  
  
  ❌ &lt;code&gt;SDK location not found&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Fix:&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;cd &lt;/span&gt;android
gradlew clean
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ensure &lt;code&gt;ANDROID_HOME&lt;/code&gt; is set.&lt;/p&gt;




&lt;h3&gt;
  
  
  ❌ &lt;code&gt;react-native-safe-area-context missing&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Fix:&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
cd &lt;/span&gt;android &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; gradlew clean
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  ❌ Emulator detected but app not launching
&lt;/h3&gt;

&lt;p&gt;Fix:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;adb kill-server
adb start-server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Next Steps After Hello World
&lt;/h2&gt;

&lt;p&gt;Once setup is done, learn:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Components (&lt;code&gt;View&lt;/code&gt;, &lt;code&gt;Text&lt;/code&gt;, &lt;code&gt;Image&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Navigation (&lt;code&gt;react-navigation&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Styling (&lt;code&gt;StyleSheet&lt;/code&gt;, NativeWind)&lt;/li&gt;
&lt;li&gt;API calls (&lt;code&gt;fetch&lt;/code&gt;, Axios)&lt;/li&gt;
&lt;li&gt;State management (Context, Redux)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;You learned how to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set up React Native environment&lt;/li&gt;
&lt;li&gt;Create a new project&lt;/li&gt;
&lt;li&gt;Run Android emulator&lt;/li&gt;
&lt;li&gt;Write and run a Hello World app&lt;/li&gt;
&lt;li&gt;Understand project structure&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This foundation is enough to start building &lt;strong&gt;real mobile applications&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
      <category>reactnative</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>🚀 Where `npx` Exists &amp; What You Can Change (Deep Practical Guide)</title>
      <dc:creator>lucky chauhan</dc:creator>
      <pubDate>Fri, 26 Dec 2025 09:15:45 +0000</pubDate>
      <link>https://dev.to/luckychauhan/where-npx-exists-what-you-can-change-deep-practical-guide-3df4</link>
      <guid>https://dev.to/luckychauhan/where-npx-exists-what-you-can-change-deep-practical-guide-3df4</guid>
      <description>&lt;p&gt;&lt;code&gt;npx&lt;/code&gt; is often misunderstood as a single command or binary. In reality, it is an &lt;strong&gt;execution chain&lt;/strong&gt; composed of multiple layers involving the shell, PATH resolution, Node.js, npm internals, and environment variables.&lt;br&gt;
Because of this design, you can &lt;strong&gt;change its location, runtime behavior, and even influence port usage indirectly&lt;/strong&gt;—without modifying &lt;code&gt;npx&lt;/code&gt; source code.&lt;/p&gt;


&lt;h2&gt;
  
  
  🔍 &lt;code&gt;npx&lt;/code&gt; Is Not a Single File — It’s a Chain
&lt;/h2&gt;

&lt;p&gt;Physically and logically, &lt;code&gt;npx&lt;/code&gt; exists as a multi-step pipeline:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Shell
 ↓
npx / npx.cmd (shim)
 ↓
Node.js runtime
 ↓
npx-cli.js (npm internal JS logic)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Key implication:&lt;br&gt;
You can control &lt;strong&gt;which &lt;code&gt;npx&lt;/code&gt; runs&lt;/strong&gt; and &lt;strong&gt;how it behaves&lt;/strong&gt; by changing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PATH order&lt;/li&gt;
&lt;li&gt;Node version&lt;/li&gt;
&lt;li&gt;npm configuration&lt;/li&gt;
&lt;li&gt;environment variables&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  🪟 Windows: Where &lt;code&gt;npx&lt;/code&gt; Lives &amp;amp; What You Can Modify
&lt;/h2&gt;
&lt;h3&gt;
  
  
  📍 Default Physical Locations
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Program Files\nodejs\npx.cmd
C:\Program Files\nodejs\node_modules\npm\bin\npx-cli.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;npx.cmd&lt;/code&gt; → thin command shim (no logic)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;npx-cli.js&lt;/code&gt; → actual JavaScript implementation of &lt;code&gt;npx&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;npx.cmd&lt;/code&gt; only forwards arguments to Node, which executes &lt;code&gt;npx-cli.js&lt;/code&gt;.&lt;/p&gt;


&lt;h3&gt;
  
  
  🔧 Practical Things You Can Change on Windows
&lt;/h3&gt;
&lt;h4&gt;
  
  
  1️⃣ PATH Order Controls Which &lt;code&gt;npx&lt;/code&gt; Runs
&lt;/h4&gt;

&lt;p&gt;Check all available &lt;code&gt;npx&lt;/code&gt; commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight batchfile"&gt;&lt;code&gt;&lt;span class="nb"&gt;where&lt;/span&gt; &lt;span class="kd"&gt;npx&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Program Files\nodejs\npx.cmd
C:\Users\You\AppData\Roaming\npm\npx.cmd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 The &lt;strong&gt;first match in PATH wins&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Inspect PATH:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight batchfile"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;%PATH%&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reordering PATH immediately switches:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;active Node version&lt;/li&gt;
&lt;li&gt;active npm&lt;/li&gt;
&lt;li&gt;active npx&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No reinstall required.&lt;/p&gt;




&lt;h4&gt;
  
  
  2️⃣ Multiple Node Versions = Multiple &lt;code&gt;npx&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;If you use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;nvm&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;fnm&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;or multiple manual Node installs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each Node installation ships with its &lt;strong&gt;own npm and its own &lt;code&gt;npx&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Rule:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Change Node → npm changes → npx changes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This explains why &lt;code&gt;npx&lt;/code&gt; behavior or version may differ across terminals or projects.&lt;/p&gt;




&lt;h2&gt;
  
  
  🐧 macOS / Linux: Location &amp;amp; Override Mechanics
&lt;/h2&gt;

&lt;h3&gt;
  
  
  📍 Default Location
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;which npx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Typical output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/usr/local/bin/npx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check what it actually points to:&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;ls&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;which npx&lt;span class="si"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Usually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx -&amp;gt; ../lib/node_modules/npm/bin/npx-cli.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 This is a &lt;strong&gt;symlink&lt;/strong&gt;, not a real binary.&lt;/p&gt;




&lt;h3&gt;
  
  
  🔧 Switching &lt;code&gt;npx&lt;/code&gt; via PATH
&lt;/h3&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;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;~/.nvm/versions/node/v20.x.x/bin:&lt;span class="nv"&gt;$PATH&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Effect:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx → new Node → new npm → new npx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No config files touched—only PATH.&lt;/p&gt;




&lt;h2&gt;
  
  
  🌐 How Port Changes Are Related to &lt;code&gt;npx&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Important clarification:&lt;br&gt;
&lt;code&gt;npx&lt;/code&gt; &lt;strong&gt;does not control ports&lt;/strong&gt;.&lt;br&gt;
It only &lt;strong&gt;passes environment variables and arguments&lt;/strong&gt; to the tool it runs.&lt;/p&gt;
&lt;h3&gt;
  
  
  Common Tools Run via &lt;code&gt;npx&lt;/code&gt;
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx vite
npx react-native start
npx next dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;These tools read:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;process.env.PORT&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;CLI flags like &lt;code&gt;--port&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;
  
  
  🔧 Changing Port While Using &lt;code&gt;npx&lt;/code&gt;
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Method 1: Environment Variable (Preferred)
&lt;/h4&gt;

&lt;p&gt;macOS / Linux:&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="nv"&gt;PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;4000 npx vite
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Windows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight batchfile"&gt;&lt;code&gt;&lt;span class="kd"&gt;set&lt;/span&gt; &lt;span class="kd"&gt;PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;4000&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="kd"&gt;npx&lt;/span&gt; &lt;span class="kd"&gt;vite&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Method 2: CLI Flag
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx vite &lt;span class="nt"&gt;--port&lt;/span&gt; 4000
npx next dev &lt;span class="nt"&gt;-p&lt;/span&gt; 4000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Why This Works
&lt;/h3&gt;

&lt;p&gt;Execution flow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx → Node child process → env variables → tool logic
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;npx&lt;/code&gt; simply forwards context.&lt;br&gt;
The &lt;strong&gt;tool decides the port&lt;/strong&gt;, not &lt;code&gt;npx&lt;/code&gt;.&lt;/p&gt;


&lt;h2&gt;
  
  
  ⚙️ npm Config Changes That Affect &lt;code&gt;npx&lt;/code&gt;
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Cache Location (Critical in Real Systems)
&lt;/h3&gt;

&lt;p&gt;Check current cache:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm config get cache
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change cache directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm config &lt;span class="nb"&gt;set &lt;/span&gt;cache D:&lt;span class="se"&gt;\n&lt;/span&gt;pm-cache
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Effects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;npx&lt;/code&gt; downloads temporary packages to new location&lt;/li&gt;
&lt;li&gt;Fixes permission issues&lt;/li&gt;
&lt;li&gt;Improves disk performance&lt;/li&gt;
&lt;li&gt;Helps in CI/CD environments&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧪 Bypassing &lt;code&gt;npx&lt;/code&gt; Entirely (Proof of Internals)
&lt;/h2&gt;

&lt;p&gt;You can execute &lt;code&gt;npx&lt;/code&gt; directly via Node:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node C:&lt;span class="se"&gt;\P&lt;/span&gt;rogram Files&lt;span class="se"&gt;\n&lt;/span&gt;odejs&lt;span class="se"&gt;\n&lt;/span&gt;ode_modules&lt;span class="se"&gt;\n&lt;/span&gt;pm&lt;span class="se"&gt;\b&lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;px-cli.js create-react-app app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This proves:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;npx&lt;/code&gt; is pure JavaScript&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;npx.cmd&lt;/code&gt; / symlink is optional&lt;/li&gt;
&lt;li&gt;Node.js is mandatory&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧠 Real-World Summary
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;Can You Change It?&lt;/th&gt;
&lt;th&gt;How&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;npx&lt;/code&gt; location&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;PATH / Node version&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;npx&lt;/code&gt; behavior&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;Fixed npm logic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Port&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;Env variables / flags&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cache path&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;npm config&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Node runtime&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;nvm / fnm&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;npm version&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;Upgrade / downgrade&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  🧩 Final Mental Model
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PATH decides npx
npx decides npm context
npm decides cache
tool decides port
&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%2Fz7s68yugohn1z1u6g6wr.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%2Fz7s68yugohn1z1u6g6wr.gif" width="186" height="186"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>npx</category>
      <category>node</category>
      <category>javascript</category>
      <category>npm</category>
    </item>
    <item>
      <title>Understanding npx How It Really Works</title>
      <dc:creator>lucky chauhan</dc:creator>
      <pubDate>Wed, 24 Dec 2025 06:50:26 +0000</pubDate>
      <link>https://dev.to/luckychauhan/understanding-npx-how-it-really-works-5g3j</link>
      <guid>https://dev.to/luckychauhan/understanding-npx-how-it-really-works-5g3j</guid>
      <description>&lt;p&gt;npx stands for &lt;strong&gt;Node Package Execute&lt;/strong&gt;. &lt;code&gt;npx&lt;/code&gt; is one of the most-used tools in Node.js and yet its internals are not commonly understood. Most developers think that &lt;code&gt;npx&lt;/code&gt; just &lt;em&gt;downloads and runs packages&lt;/em&gt;. That's only the &lt;strong&gt;last step&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In practice, &lt;strong&gt;&lt;code&gt;npx&lt;/code&gt; resolves an executable through a strict, ordered search process&lt;/strong&gt;, and will install a package &lt;strong&gt;only if nothing is found locally or globally&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;npx&lt;/code&gt; does the following:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;npx&lt;/code&gt; searches for an executable and runs it.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It downloads it temporarily and runs the executable, if the executable is not available locally or globally.&lt;/p&gt;

&lt;p&gt;Consider &lt;code&gt;npx&lt;/code&gt; as an &lt;strong&gt;executable resolver&lt;/strong&gt;, not a package manager.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;npx&lt;/code&gt; can both &lt;strong&gt;install&lt;/strong&gt; and &lt;strong&gt;execute&lt;/strong&gt; a package &lt;strong&gt;only if that package exposes an executable&lt;/strong&gt; (via the &lt;code&gt;bin&lt;/code&gt; field).&lt;/p&gt;

&lt;p&gt;If the package is a &lt;strong&gt;CLI tool&lt;/strong&gt;, &lt;code&gt;npx&lt;/code&gt; will:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Download it temporarily (if not already available)&lt;/li&gt;
&lt;li&gt;Execute its binary&lt;/li&gt;
&lt;li&gt;Remove it after execution (unless cached)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Examples&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx vite&lt;/code&gt;&lt;br&gt;&lt;br&gt;
&lt;code&gt;vite&lt;/code&gt; is a CLI package that exposes a binary. &lt;code&gt;npx&lt;/code&gt; installs it (if missing) and runs the Vite dev server.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx express&lt;/code&gt;&lt;br&gt;&lt;br&gt;
The &lt;code&gt;express&lt;/code&gt; package is a &lt;strong&gt;library&lt;/strong&gt;, not a CLI. It does &lt;strong&gt;not&lt;/strong&gt; expose an executable, so &lt;code&gt;npx express&lt;/code&gt; fails.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Rule&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx&lt;/code&gt; works only with packages that provide executables.&lt;br&gt;&lt;br&gt;
Libraries without a &lt;code&gt;bin&lt;/code&gt; entry cannot be executed using &lt;code&gt;npx&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Exact Resolution Order (Quick Scan)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;What npx does?
Searches for a file and executes it.

Search Step-1
    Searches for package.json in current working directory
    Searches for name key in the json
    Searches for bin key

Search Step-2
    Searches for node_modules\.bin\hello in current working directory
    And executes this file

Search Step-3
    Searches for hello in global npm folder
    And executes this file

Search Step-4
    Searches for hello package in npx cache
    And executes this file

Search Step-5
    Searches for hello package in npm registry
    Prompts to install the package if found
    Downloads and installs
&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%2Fggux6xuq4yhpqsbar94z.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%2Fggux6xuq4yhpqsbar94z.gif" width="450" height="250"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Execution stops immediately when a match is found.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Deep Explanation: How Each Step Works
&lt;/h2&gt;

&lt;p&gt;Below is the Deep Explanation of each Step &lt;/p&gt;

&lt;h2&gt;
  
  
  Step: Project &lt;code&gt;package.json&lt;/code&gt; — Project-Scoped CLI (Highest Priority)
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;npx&lt;/code&gt; first checks whether the &lt;strong&gt;current working directory&lt;/strong&gt; contains a &lt;code&gt;package.json&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If found, it inspects &lt;strong&gt;two fields&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;→ &lt;code&gt;name&lt;/code&gt;&lt;br&gt;
→ &lt;code&gt;bin&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If the executed command matches:&lt;/p&gt;

&lt;p&gt;→ the project &lt;code&gt;name&lt;/code&gt;&lt;br&gt;
→ a key exposed in the &lt;code&gt;bin&lt;/code&gt; field&lt;/p&gt;

&lt;p&gt;then &lt;code&gt;npx&lt;/code&gt; executes the mapped file &lt;strong&gt;directly from the project&lt;/strong&gt;, without any global installation.&lt;/p&gt;
&lt;h2&gt;
  
  
  Minimal Working Example (Test This Locally)
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Create a new project folder
&lt;/h3&gt;

&lt;p&gt;→ Open a terminal&lt;br&gt;
→ Run:&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;mkdir &lt;/span&gt;hello-project
&lt;span class="nb"&gt;cd &lt;/span&gt;hello-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Initialize &lt;code&gt;package.json&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;→ Run:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;→ Update &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="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;"hello"&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;"1.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;"bin"&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;"hello"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"./index.js"&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;h3&gt;
  
  
  Create the executable file
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Folder structure:&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;hello-project/
├── package.json
└── index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;→ Create &lt;code&gt;index.js&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="cp"&gt;#!/usr/bin/env node
&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello from project-scoped CLI&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Make the file executable (Linux / macOS)
&lt;/h3&gt;

&lt;p&gt;→ Run:&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;chmod&lt;/span&gt; +x index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;→ Windows users can skip this step&lt;/p&gt;

&lt;h3&gt;
  
  
  Run the command using &lt;code&gt;npx&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;→ Execute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx hello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;→ Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello from project-scoped CLI
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What Happens Internally
&lt;/h2&gt;

&lt;p&gt;When you run &lt;code&gt;npx hello&lt;/code&gt;, &lt;code&gt;npx&lt;/code&gt; performs the following:&lt;/p&gt;

&lt;p&gt;→ Detects &lt;code&gt;package.json&lt;/code&gt;&lt;br&gt;
→ Reads &lt;code&gt;name&lt;/code&gt; → &lt;code&gt;hello&lt;/code&gt;&lt;br&gt;
→ Resolves &lt;code&gt;bin&lt;/code&gt; → &lt;code&gt;./index.js&lt;/code&gt;&lt;br&gt;
→ Executes the mapped file&lt;/p&gt;

&lt;p&gt;→ No downloads&lt;br&gt;
→ No global installs&lt;br&gt;
→ No cache lookup&lt;/p&gt;
&lt;h2&gt;
  
  
  Why This Matters
&lt;/h2&gt;

&lt;p&gt;→ Enables &lt;strong&gt;project-scoped CLIs&lt;/strong&gt;&lt;br&gt;
→ Prevents global version conflicts&lt;br&gt;
→ Ensures project and CLI stay in sync&lt;br&gt;
→ Ideal for internal tooling&lt;/p&gt;


&lt;h3&gt;
  
  
  Step 2: Local &lt;code&gt;node_modules/.bin&lt;/code&gt; (Preferred Execution)
&lt;/h3&gt;

&lt;p&gt;If Step 1 fails, &lt;code&gt;npx&lt;/code&gt; checks the &lt;strong&gt;local project’s executable directory&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;./node_modules/.bin/hello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This directory is &lt;strong&gt;automatically created by npm&lt;/strong&gt; when a dependency exposes a &lt;code&gt;bin&lt;/code&gt; field in its &lt;code&gt;package.json&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example: Local CLI Installation
&lt;/h3&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;hello-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This produces the following structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;project-root/
├─ package.json
├─ node_modules/
│  ├─ .bin/
│  │  ├─ hello          (macOS / Linux)
│  │  ├─ hello.cmd      (Windows)
│  │  └─ hello.ps1      (Windows PowerShell)
│  └─ hello-cli/
│     ├─ package.json
│     └─ index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;.bin&lt;/code&gt; files are &lt;strong&gt;shims&lt;/strong&gt; generated by npm that point to the actual executable defined in the package’s &lt;code&gt;bin&lt;/code&gt; field.&lt;/p&gt;

&lt;h3&gt;
  
  
  Execution
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx hello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;npx&lt;/code&gt; resolves and executes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./node_modules/.bin/hello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No global lookup occurs once a local match is found.&lt;/p&gt;

&lt;h4&gt;
  
  
  Key rule
&lt;/h4&gt;

&lt;p&gt;Local project executables &lt;strong&gt;always override&lt;/strong&gt; global ones.&lt;/p&gt;

&lt;p&gt;This guarantees:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Version consistency per project&lt;/li&gt;
&lt;li&gt;Predictable CLI behavior&lt;/li&gt;
&lt;li&gt;Reproducible development and CI environments&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Step 3: Global npm Binary Folder
&lt;/h3&gt;

&lt;p&gt;If no local executable exists, &lt;code&gt;npx&lt;/code&gt; checks the &lt;strong&gt;global npm executable path&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In modern npm versions, the &lt;code&gt;npm bin -g&lt;/code&gt; command no longer exists. Instead, &lt;code&gt;npx&lt;/code&gt; derives the global binary location from the global npm root:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Example (Windows):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Users\username\AppData\Roaming\npm\node_modules
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Global CLI executables are exposed &lt;strong&gt;one level above&lt;/strong&gt; this directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Users\username\AppData\Roaming\npm\
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If a matching executable (for example &lt;code&gt;hello.cmd&lt;/code&gt; or &lt;code&gt;hello&lt;/code&gt;) exists in this location and is available in the system &lt;code&gt;PATH&lt;/code&gt;, &lt;code&gt;npx&lt;/code&gt; executes it immediately.&lt;/p&gt;

&lt;h4&gt;
  
  
  Reason for lower priority
&lt;/h4&gt;

&lt;p&gt;Global CLIs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Are shared across all projects&lt;/li&gt;
&lt;li&gt;Can introduce version mismatches&lt;/li&gt;
&lt;li&gt;Reduce reproducibility across environments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For this reason, &lt;code&gt;npx&lt;/code&gt; always prefers project-local binaries over global ones.&lt;/p&gt;




&lt;h3&gt;
  
  
  Step 4: npx Cache — Fast Reuse
&lt;/h3&gt;

&lt;p&gt;If the executable is still not found locally or globally, &lt;code&gt;npx&lt;/code&gt; checks its &lt;strong&gt;local execution cache&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This cache is maintained by &lt;strong&gt;npm&lt;/strong&gt; and reused by &lt;code&gt;npx&lt;/code&gt; to avoid unnecessary network calls.&lt;/p&gt;

&lt;h4&gt;
  
  
  What the npx cache does
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Stores previously downloaded CLI packages (temporary installs)&lt;/li&gt;
&lt;li&gt;Reuses exact package versions across executions&lt;/li&gt;
&lt;li&gt;Eliminates repeated downloads from the npm registry&lt;/li&gt;
&lt;li&gt;Significantly improves execution speed for recurring commands&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Where the cache lives
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;npx&lt;/code&gt; uses npm’s cache directory.&lt;/p&gt;

&lt;p&gt;Check the active cache path:&lt;/p&gt;

&lt;p&gt;Check the active cache path:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm config get cache
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example output:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Windows&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;C:\Users\&amp;lt;username&amp;gt;\AppData\Local\npm-cache
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Linux / macOS&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/&amp;lt;username&amp;gt;/.npm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;npx&lt;/code&gt; creates and manages its execution cache inside this directory:&lt;/p&gt;




&lt;h3&gt;
  
  
  Step 5: npm Registry (Last Resort)
&lt;/h3&gt;

&lt;p&gt;When all previous steps fail, &lt;code&gt;npx&lt;/code&gt; queries the npm registry.&lt;/p&gt;

&lt;p&gt;If a &lt;code&gt;hello&lt;/code&gt;-named package does exist:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The package is downloaded&lt;/li&gt;
&lt;li&gt;Its &lt;code&gt;bin&lt;/code&gt; entry is resolved&lt;/li&gt;
&lt;li&gt;The executable is run immediately&lt;/li&gt;
&lt;li&gt;The package is cached&lt;/li&gt;
&lt;/ol&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx create-react-app my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nothing is installed globally, nor saved to &lt;code&gt;package.json&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This behavior is tightly integrated with &lt;strong&gt;Node.js&lt;/strong&gt;, npm’s binary linking system, and shebang-based execution.&lt;/p&gt;




&lt;h2&gt;
  
  
  Mental Model to Remember
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;npx&lt;/code&gt; = resolve an executable, not install a dependency.&lt;/p&gt;

&lt;p&gt;Installation occurs &lt;strong&gt;only when resolution fails&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Takeaway
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;npx&lt;/code&gt; is a &lt;strong&gt;command runner&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Local project tools always win&lt;/li&gt;
&lt;li&gt;Global tools are fallback&lt;/li&gt;
&lt;li&gt;Cache avoids re-downloads&lt;/li&gt;
&lt;li&gt;The registry fetch is the last step&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use &lt;code&gt;npx&lt;/code&gt; when you want:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One-off CLI usage&lt;/li&gt;
&lt;li&gt;Zero global installs&lt;/li&gt;
&lt;li&gt;Version-safe tooling&lt;/li&gt;
&lt;li&gt;Clean developer environments&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Questions to Think About
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Q1:&lt;/strong&gt; If no version is specified, how does &lt;code&gt;npx&lt;/code&gt; know which version to download?&lt;br&gt;
&lt;strong&gt;Q2:&lt;/strong&gt; What if the same command exists locally and globally?&lt;br&gt;
&lt;strong&gt;Q3:&lt;/strong&gt; Why is &lt;code&gt;node_modules/.bin&lt;/code&gt; preferred over global binaries in &lt;code&gt;npx&lt;/code&gt; resolution?&lt;br&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%2Fej6xvzhs69ry3jcbdc5u.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%2Fej6xvzhs69ry3jcbdc5u.gif" alt="Animated illustration showing npx resolving a command step by step before downloading anything" width="478" height="350"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>npx</category>
      <category>npm</category>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>The Secret Trick to Customizing Console Logs with CSS</title>
      <dc:creator>lucky chauhan</dc:creator>
      <pubDate>Thu, 15 May 2025 03:24:32 +0000</pubDate>
      <link>https://dev.to/luckychauhan/the-secret-trick-to-customizing-console-logs-with-css-150n</link>
      <guid>https://dev.to/luckychauhan/the-secret-trick-to-customizing-console-logs-with-css-150n</guid>
      <description>&lt;p&gt;&lt;strong&gt;Tired of boring, plain-text console logs?&lt;/strong&gt; Did you know you can style your browser’s console output with &lt;strong&gt;colors, custom fonts, backgrounds, and even animations&lt;/strong&gt;—all using a simple JavaScript trick?  &lt;/p&gt;

&lt;p&gt;In this post, you’ll learn how to use the &lt;strong&gt;&lt;code&gt;%c&lt;/code&gt;&lt;/strong&gt; formatter to apply CSS styling to &lt;code&gt;console.log()&lt;/code&gt; messages, making debugging more visually intuitive and even fun!  &lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;✨ Why Style Console Logs?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Before we dive into the code, here’s why you should care:&lt;br&gt;&lt;br&gt;
✅ &lt;strong&gt;Highlight important logs&lt;/strong&gt; (errors in red, warnings in yellow)&lt;br&gt;&lt;br&gt;
✅ &lt;strong&gt;Organize debug output&lt;/strong&gt; (API calls vs. state changes)&lt;br&gt;&lt;br&gt;
✅ &lt;strong&gt;Make debugging more enjoyable&lt;/strong&gt; (because who doesn’t love colors?)  &lt;/p&gt;


&lt;h2&gt;
  
  
  &lt;strong&gt;🛠 How It Works: The &lt;code&gt;%c&lt;/code&gt; Formatter&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The secret is the &lt;strong&gt;&lt;code&gt;%c&lt;/code&gt;&lt;/strong&gt; placeholder in &lt;code&gt;console.log()&lt;/code&gt;. It tells the browser: &lt;em&gt;“The next argument is CSS—apply it to this text!”&lt;/em&gt;  &lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;Basic Syntax&lt;/strong&gt;
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;%cStyled Text&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;CSS goes here&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Example: Colored &amp;amp; Bold Log&lt;/strong&gt;
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;%cHello, Console!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;color: white; background: #007BFF; font-weight: bold; padding: 4px;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This logs a &lt;strong&gt;blue-background, bold, white text&lt;/strong&gt; message.  &lt;/p&gt;


&lt;h2&gt;
  
  
  &lt;strong&gt;🎨 Advanced Styling Tricks&lt;/strong&gt;
&lt;/h2&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;1. Multiple Styles in One Log&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Use multiple &lt;code&gt;%c&lt;/code&gt; placeholders for different styles:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;%cError:%c File not found!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;color: red; font-weight: bold;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;color: #333;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;2. Backgrounds, Borders &amp;amp; Padding&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Make logs stand out like notifications:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;%cSUCCESS&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;background: #28A745; color: white; padding: 4px 8px; border-radius: 4px;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;3. Fun with Fonts &amp;amp; Shadows&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;%c✨ Debug Mode Activated!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;font-family: sans-serif; font-size: 18px; text-shadow: 1px 1px 2px #ccc;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  &lt;strong&gt;🚀 Practical Uses&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Color-code log levels&lt;/strong&gt; (errors, warnings, info)
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Highlight API request/response logs&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Make debugging sessions less monotonous&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;🔍 Try It Yourself!&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Open &lt;strong&gt;DevTools&lt;/strong&gt; (&lt;code&gt;F12&lt;/code&gt; or &lt;code&gt;Ctrl+Shift+I&lt;/code&gt;).
&lt;/li&gt;
&lt;li&gt;Paste any example above into the console.
&lt;/li&gt;
&lt;li&gt;Experiment with your own styles!
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Pro Tip:&lt;/strong&gt; Combine this with &lt;code&gt;console.group()&lt;/code&gt; for neatly organized logs.  &lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;💬 Your Challenge&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;What’s the craziest style you can create? Try:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Gradient text
&lt;/li&gt;
&lt;li&gt;Animated logs (using &lt;code&gt;@keyframes&lt;/code&gt;)
&lt;/li&gt;
&lt;li&gt;A full-width console "header"
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;📌 Key Takeaways&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;✔ Use &lt;code&gt;%c&lt;/code&gt; to inject CSS into &lt;code&gt;console.log()&lt;/code&gt;.&lt;br&gt;&lt;br&gt;
✔ Style text, backgrounds, borders, and more.&lt;br&gt;&lt;br&gt;
✔ Great for debugging, logging, and fun experiments.  &lt;/p&gt;

&lt;p&gt;Now go make your console logs &lt;strong&gt;pop with color!&lt;/strong&gt; 🎉  &lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Tags:&lt;/strong&gt; #JavaScriptTips #WebDevelopment #Debugging #FrontEnd  &lt;/p&gt;

</description>
      <category>consolehacks</category>
      <category>css</category>
      <category>javascripttips</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
