<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Naren on Medium]]></title>
        <description><![CDATA[Stories by Naren on Medium]]></description>
        <link>https://medium.com/@narenprasanth.dev?source=rss-2cfe37e1c3cb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*AlSprX_1YjgpeHb9</url>
            <title>Stories by Naren on Medium</title>
            <link>https://medium.com/@narenprasanth.dev?source=rss-2cfe37e1c3cb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 09:05:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@narenprasanth.dev/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[What If Your AI Developer Actually Remembered Things? The Answer Is Simpler Than You Think]]></title>
            <link>https://medium.com/@narenprasanth.dev/what-if-your-ai-developer-actually-remembered-things-the-answer-is-simpler-than-you-think-084e7335b846?source=rss-2cfe37e1c3cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/084e7335b846</guid>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[ai-coding-agent]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <dc:creator><![CDATA[Naren]]></dc:creator>
            <pubDate>Mon, 16 Mar 2026 11:59:47 GMT</pubDate>
            <atom:updated>2026-03-16T12:09:14.234Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JVcf1kDV6dmJblW3mJ2oMg.jpeg" /></figure><p>Imagine you hired a brilliant freelance developer — let’s call them Alex.</p><p>Alex is incredibly fast. Alex can write code, run tests, debug errors, and refactor entire modules. But every morning when Alex shows up, they remember nothing from yesterday. Zero. You have to re-explain everything from scratch.</p><p>This is the exact problem that <em>AGENTS.md</em> and Codex Hooks solve — in two very different but complementary ways.</p><p>Let’s walk through both with real examples.</p><h4><strong>AGENTS.md — The Briefing Document You Give Alex Every Morning</strong></h4><p><em>AGENTS.md</em> is a plain text file you put in your project. Before Codex touches a single file, it reads this document. Think of it as the onboarding guide for your AI developer.</p><p>Say you’re working on an e-commerce app called ShopFast. Your <em>AGENTS.md</em> might say:</p><p><strong>AGENTS.md</strong></p><pre>→  We use pnpm (not npm or yarn). Always.<br>→  Run: pnpm test before committing any change.<br>→  Never touch the /payments folder without asking me first.<br>→  All new components go in /src/components.<br>→  We follow the Airbnb ESLint ruleset.<br>→  Write a JSDoc comment for every exported function.</pre><p><strong>Where do you put AGENTS.md?</strong></p><p>🌍 <strong>Global (~/.codex/AGENTS.md): </strong>Applies to every project. Great for personal preferences like always preferring TypeScript or always running prettier before committing.</p><p>📁 <strong>Project root (./AGENTS.md): </strong>Applies only to that project. Team-specific rules, test commands, folder structure.</p><p>📂 <strong>Subfolder (/backend/AGENTS.md): </strong>Even more specific rules for just that part of the codebase. Codex merges all of them together automatically.</p><h4><strong>The thing AGENTS.md cannot do</strong></h4><p>It is a static text file. It cannot run code. It cannot check what is happening right now. It cannot send you a notification. It cannot react to events.</p><p>❌<strong> AGENTS.md cannot do these things:</strong></p><pre>→  &quot;Load today&#39;s open GitHub issues when the session starts&quot;<br>→  &quot;Ping me on Slack when the coding task is done&quot;<br>→  &quot;Block any tool call that touches the production database&quot;<br>→  &quot;Show me the last 5 commits every time I open a new session&quot;</pre><h3><strong>Codex Hooks — Alex Gets a Phone That Can Ring</strong></h3><p>If <em>AGENTS.md</em> is the morning briefing note, Codex Hooks are the phone calls, alarms, and automations that happen during the workday.</p><p>A hook is a small script that runs automatically when something specific happens — called a lifecycle event. Right now there are two live events:</p><p>🟢 <strong>SessionStart — </strong>fires the moment a new Codex session begins<br>🔴 <strong>Stop — </strong>fires when Codex finishes a task turn</p><p><strong>Real Example 1: SessionStart Hook — Load live context</strong></p><p>Every morning you open Codex to work on ShopFast. With just <em>AGENTS.md</em>, Alex knows the rules but does not know what’s on your plate today.</p><p>With a <em>SessionStart</em> hook, the moment Codex opens, a small script runs automatically and tells it:</p><p>🚀<strong> What your SessionStart hook loads automatically:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A2YthO8gUorl9cIsnAiMbQ.png" /></figure><blockquote>🔧<strong> How it works under the hood:</strong></blockquote><blockquote>Your hook is a simple shell script that calls the GitHub CLI, runs git log, and prints the results. Codex reads that output and treats it as live context for the session. It’s just a bash script wired to an event.</blockquote><p><strong>Real Example 2: Stop Hook — Get notified when done</strong></p><p>You ask Codex: “Refactor the entire checkout module and write tests for everything.” That’s going to take a while. You go make coffee.</p><p>⏰<strong> Without a Stop hook:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4lEq1K3FjV6RWcAiWh1gdA.png" /></figure><p>✅<strong> With a Stop hook:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lLplQfTM1xEqDXdz-KjQ2A.png" /></figure><p><strong>Real Example 3: PreToolUse Hook — The safety guard (coming soon)</strong></p><p>This event is not live yet but it is the most important one. Imagine you are running Codex on a project that has both a staging database and a production database.</p><p>Codex is smart — but you never want it touching production without explicit approval.</p><p>🛡️<strong> With a PreToolUse hook, you write one rule:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hqCaKiRmP7i0isy2bpTy7w.png" /></figure><blockquote>🔑<strong> This is the key difference from AGENTS.md:</strong></blockquote><blockquote>AGENTS.md says “please don’t touch production”. A PreToolUse hook PREVENTS it. One is a polite request. The other is a locked door.</blockquote><p><strong>Side-by-Side: AGENTS.md vs Codex Hooks</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PtTaa6L7krBNaS4hYR9nrQ.png" /></figure><p><strong>Sample Hook Script</strong></p><pre>{<br>  &quot;hooks&quot;: {<br>    &quot;SessionStart&quot;: [<br>      {<br>        &quot;hooks&quot;: [<br>          {<br>            &quot;type&quot;: &quot;command&quot;,<br>            &quot;command&quot;: &quot;echo &#39;🌿 Branch:&#39; $(git branch --show-current) &amp;&amp; echo &#39;📝 Last commit:&#39; $(git log --oneline -1) &amp;&amp; echo &#39;📁 Changed files:&#39; $(git status --short | wc -l | tr -d &#39; &#39;)&quot;,<br>            &quot;statusMessage&quot;: &quot;Loading git context...&quot;,<br>            &quot;timeout&quot;: 10<br>          },<br>          {<br>            &quot;type&quot;: &quot;command&quot;,<br>            &quot;command&quot;: &quot;gh issue list --assignee @me --limit 5 --json number,title --jq &#39;.[] | \&quot;  #\\(.number)  \\(.title)\&quot;&#39; 2&gt;/dev/null || echo &#39;  No open issues assigned to you&#39;&quot;,<br>            &quot;statusMessage&quot;: &quot;Fetching your GitHub issues...&quot;,<br>            &quot;timeout&quot;: 15<br>          },<br>          {<br>            &quot;type&quot;: &quot;command&quot;,<br>            &quot;command&quot;: &quot;pnpm test --silent 2&gt;/dev/null &amp;&amp; echo &#39;✅ All tests passing&#39; || echo &#39;❌ Tests failing — fix before starting&#39;&quot;,<br>            &quot;statusMessage&quot;: &quot;Running test pulse...&quot;,<br>            &quot;timeout&quot;: 30<br>          },<br>          {<br>            &quot;type&quot;: &quot;command&quot;,<br>            &quot;command&quot;: &quot;UNPUSHED=$(git log origin/$(git branch --show-current)..HEAD --oneline 2&gt;/dev/null | wc -l | tr -d &#39; &#39;) &amp;&amp; [ \&quot;$UNPUSHED\&quot; -gt 0 ] &amp;&amp; echo \&quot;⚠️  You have $UNPUSHED unpushed commit(s)\&quot; || echo &#39;✅ All commits pushed&#39;&quot;,<br>            &quot;statusMessage&quot;: &quot;Checking unpushed commits...&quot;,<br>            &quot;timeout&quot;: 10<br>          },<br>          {<br>            &quot;type&quot;: &quot;command&quot;,<br>            &quot;command&quot;: &quot;echo &#39;🕐 Session started at&#39; $(date &#39;+%Y-%m-%d %H:%M:%S&#39;) &gt;&gt; ~/.codex/logs/shopfast.log &amp;&amp; echo &#39;📋 Session logged. Ready to build!&#39;&quot;,<br>            &quot;statusMessage&quot;: &quot;Logging session start...&quot;,<br>            &quot;timeout&quot;: 5<br>          }<br>        ]<br>      }<br>    ],<br><br>    &quot;Stop&quot;: [<br>      {<br>        &quot;hooks&quot;: [<br>          {<br>            &quot;type&quot;: &quot;command&quot;,<br>            &quot;command&quot;: &quot;echo &#39;[TURN COMPLETE]&#39; $(date &#39;+%Y-%m-%d %H:%M:%S&#39;) &#39;Branch:&#39; $(git branch --show-current) &#39;Changed:&#39; $(git status --short | wc -l | tr -d &#39; &#39;) &#39;file(s)&#39; &gt;&gt; ~/.codex/logs/shopfast.log&quot;,<br>            &quot;statusMessage&quot;: &quot;Logging turn to session file...&quot;,<br>            &quot;timeout&quot;: 5<br>          },<br>          {<br>            &quot;type&quot;: &quot;command&quot;,<br>            &quot;command&quot;: &quot;pnpm test --silent 2&gt;/dev/null &amp;&amp; echo &#39;✅ Tests still passing&#39; || (echo &#39;❌ Tests broke this turn — review before next prompt&#39; &amp;&amp; osascript -e &#39;display notification \&quot;Tests broke! Review output.\&quot; with title \&quot;ShopFast ⚠️\&quot; sound name \&quot;Basso\&quot;&#39; 2&gt;/dev/null)&quot;,<br>            &quot;statusMessage&quot;: &quot;Running post-turn test check...&quot;,<br>            &quot;timeout&quot;: 30<br>          },<br>          {<br>            &quot;type&quot;: &quot;command&quot;,<br>            &quot;command&quot;: &quot;[ -n \&quot;$SLACK_WEBHOOK_URL\&quot; ] &amp;&amp; curl -s -X POST \&quot;$SLACK_WEBHOOK_URL\&quot; -H &#39;Content-Type: application/json&#39; -d \&quot;{\\\&quot;text\\\&quot;:\\\&quot;✅ Codex turn complete on $(git branch --show-current) — $(git status --short | wc -l | tr -d &#39; &#39;) file(s) changed\\\&quot;}\&quot; &gt; /dev/null &amp;&amp; echo &#39;📨 Slack notified&#39; || echo &#39;⏭️  Slack webhook not set — skipping&#39;&quot;,<br>            &quot;statusMessage&quot;: &quot;Sending Slack notification...&quot;,<br>            &quot;timeout&quot;: 10<br>          },<br>          {<br>            &quot;type&quot;: &quot;command&quot;,<br>            &quot;command&quot;: &quot;osascript -e &#39;display notification \&quot;Turn complete — review the output\&quot; with title \&quot;ShopFast ✓\&quot;&#39; 2&gt;/dev/null || notify-send &#39;ShopFast ✓&#39; &#39;Codex turn complete&#39; 2&gt;/dev/null || echo &#39;🔔 Notification sent&#39;&quot;,<br>            &quot;statusMessage&quot;: &quot;Sending desktop notification...&quot;,<br>            &quot;timeout&quot;: 5<br>          },<br>          {<br>            &quot;type&quot;: &quot;command&quot;,<br>            &quot;command&quot;: &quot;afplay /System/Library/Sounds/Glass.aiff 2&gt;/dev/null || paplay /usr/share/sounds/freedesktop/stereo/complete.oga 2&gt;/dev/null || echo &#39;🔊 Audio not available on this platform&#39;&quot;,<br>            &quot;statusMessage&quot;: &quot;Playing completion sound...&quot;,<br>            &quot;timeout&quot;: 5<br>          }<br>        ]<br>      }<br>    ]<br>  }<br>}</pre><p><strong>The bottom line</strong></p><p>Codex is already a powerful coding agent. But without <em>AGENTS.md</em>, it forgets everything between sessions. Without hooks, it cannot notify you, inject live context, or enforce safety.</p><p>Add both, and you go from a powerful-but-forgetful AI to a genuinely autonomous development partner that knows your codebase, loads fresh context every session, tells you when it’s done, and cannot accidentally break production.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=084e7335b846" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Beginner’s Guide to GitHub Actions: Understanding Key Concepts and Keywords]]></title>
            <link>https://medium.com/@narenprasanth.dev/a-beginners-guide-to-github-actions-understanding-key-concepts-and-keywords-901386afbf58?source=rss-2cfe37e1c3cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/901386afbf58</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[github-actions]]></category>
            <dc:creator><![CDATA[Naren]]></dc:creator>
            <pubDate>Mon, 03 Feb 2025 09:25:57 GMT</pubDate>
            <atom:updated>2025-02-03T09:25:57.928Z</atom:updated>
            <content:encoded><![CDATA[<p>GitHub Actions is a powerful automation tool that allows developers to automate workflows directly within their GitHub repositories. Whether you’re building, testing, or deploying code, GitHub Actions can streamline your development process. However, if you’re new to GitHub Actions, the terminology and structure can be a bit overwhelming. In this blog, we’ll break down the key concepts and keywords to help you get started.</p><h4>What is GitHub Actions?</h4><p>GitHub Actions is a CI/CD (Continuous Integration/Continuous Deployment) platform that enables you to automate tasks like building, testing, and deploying your code. It uses YAML files to define workflows, which are triggered by events such as pushes, pull requests, or scheduled events.</p><h4>Key Concepts and Keywords in GitHub Actions</h4><h4>1. Workflow</h4><p>A <strong>workflow</strong> is an automated process that you define in your repository. It is composed of one or more jobs and is triggered by specific events. Workflows are defined in YAML files stored in the .github/workflows directory of your repository.</p><p>Example:</p><pre>name: CI Workflow<br>on: [push]<br>jobs:<br>  build:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - name: Checkout code<br>        uses: actions/checkout@v3</pre><h4>2. Event</h4><p>An <strong>event</strong> is a specific activity that triggers a workflow. Common events include:</p><ul><li>push: Triggered when code is pushed to a branch.</li><li>pull_request: Triggered when a pull request is created or updated.</li><li>schedule: Triggered based on a cron schedule.</li><li>workflow_dispatch: Allows manual triggering of the workflow from the GitHub UI.</li></ul><p>Example:</p><pre>on:<br>  push:<br>    branches:<br>      - main<br>  pull_request:<br>    branches:<br>      - main<br>  schedule:<br>    - cron: &#39;0 8 * * *&#39;  # Runs at 8:00 AM UTC every day</pre><h4>3. Job</h4><p>A <strong>job</strong> is a set of steps that run on the same runner (a virtual machine or container). Jobs run in parallel by default, but you can configure dependencies between jobs using the needs keyword.</p><p>Example:</p><pre>jobs:<br>  build:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - name: Checkout code<br>        uses: actions/checkout@v3<br>  test:<br>    runs-on: ubuntu-latest<br>    needs: build<br>    steps:<br>      - name: Run tests<br>        run: npm test</pre><h4>4. Step</h4><p>A <strong>step</strong> is an individual task within a job. Steps can run commands or use pre-built actions. Each step is executed in the same runner environment.</p><p>Example:</p><pre>steps:<br>  - name: Checkout code<br>    uses: actions/checkout@v3<br>  - name: Install dependencies<br>    run: npm install</pre><h4>5. Action</h4><p>An <strong>action</strong> is a reusable unit of code that performs a specific task. Actions can be written in JavaScript or Docker and are often shared in the GitHub Marketplace. You can use actions created by others or create your own.</p><p>Example:</p><pre>steps:<br>  - name: Checkout code<br>    uses: actions/checkout@v3<br>  - name: Use Node.js<br>    uses: actions/setup-node@v3<br>    with:<br>      node-version: 16</pre><h4>6. Runner</h4><p>A <strong>runner</strong> is a machine (virtual or physical) that executes jobs. GitHub provides hosted runners (e.g., ubuntu-latest, windows-latest, macos-latest), or you can host your own self-hosted runners.</p><p>Example:</p><pre>jobs:<br>  build:<br>    runs-on: ubuntu-latest</pre><h4>7. Artifact</h4><p>An <strong>artifact</strong> is a file or collection of files generated during a workflow run. Artifacts can be stored and shared between jobs or downloaded after the workflow completes.</p><p>Example:</p><pre>steps:<br>  - name: Build project<br>    run: npm run build<br>  - name: Upload artifact<br>    uses: actions/upload-artifact@v3<br>    with:<br>      name: build-output<br>      path: dist/</pre><h4>8. Secrets</h4><p><strong>Secrets</strong> are encrypted environment variables that store sensitive information like API keys or passwords. They can be accessed in workflows using the secrets context.</p><p>Example:</p><pre>steps:<br>  - name: Deploy to production<br>    run: ./deploy.sh<br>    env:<br>      API_KEY: ${{ secrets.PRODUCTION_API_KEY }}</pre><h4>9. Matrix</h4><p>A <strong>matrix</strong> allows you to run a job with multiple configurations simultaneously. This is useful for testing across different environments, platforms, or versions.</p><p>Example:</p><pre>jobs:<br>  test:<br>    runs-on: ubuntu-latest<br>    strategy:<br>      matrix:<br>        node-version: [12, 14, 16]<br>    steps:<br>      - name: Use Node.js<br>        uses: actions/setup-node@v3<br>        with:<br>          node-version: ${{ matrix.node-version }}<br>      - name: Run tests<br>        run: npm test</pre><h4>10. Context</h4><p>A <strong>context</strong> is a way to access information about the workflow run, such as the event payload, runner environment, or secrets. Contexts are accessed using the ${{ }} syntax.</p><p>Example:</p><pre>steps:<br>  - name: Print branch name<br>    run: echo &quot;Branch is ${{ github.ref }}&quot;</pre><h4>11. Environment</h4><p>An <strong>environment</strong> is a set of rules and secrets that can be applied to a job. Environments are useful for managing deployments to different stages (e.g., staging, production).</p><p>Example:</p><pre>jobs:<br>  deploy:<br>    runs-on: ubuntu-latest<br>    environment: production<br>    steps:<br>      - name: Deploy<br>        run: ./deploy.sh</pre><h4>12. Caching</h4><p><strong>Caching</strong> allows you to store and reuse files between workflow runs, such as dependencies or build outputs. This can significantly speed up your workflows.</p><p>Example:</p><pre>steps:<br>  - name: Cache node modules<br>    uses: actions/cache@v3<br>    with:<br>      path: node_modules<br>      key: ${{ runner.os }}-node-${{ hashFiles(&#39;package-lock.json&#39;) }}</pre><h4>Putting It All Together</h4><p>Here’s an example of a complete workflow that uses many of the concepts discussed above:</p><pre>name: CI/CD Pipeline<br><br>on:<br>  push:<br>    branches:<br>      - main<br>  pull_request:<br>    branches:<br>      - main<br><br>jobs:<br>  build:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - name: Checkout code<br>        uses: actions/checkout@v3<br>      - name: Install dependencies<br>        run: npm install<br>      - name: Build project<br>        run: npm run build<br>      - name: Upload artifact<br>        uses: actions/upload-artifact@v3<br>        with:<br>          name: build-output<br>          path: dist/<br><br>  test:<br>    runs-on: ubuntu-latest<br>    needs: build<br>    strategy:<br>      matrix:<br>        node-version: [12, 14, 16]<br>    steps:<br>      - name: Use Node.js<br>        uses: actions/setup-node@v3<br>        with:<br>          node-version: ${{ matrix.node-version }}<br>      - name: Run tests<br>        run: npm test<br><br>  deploy:<br>    runs-on: ubuntu-latest<br>    needs: test<br>    environment: production<br>    steps:<br>      - name: Deploy to production<br>        run: ./deploy.sh<br>        env:<br>          API_KEY: ${{ secrets.PRODUCTION_API_KEY }}</pre><h3>Conclusion</h3><p>GitHub Actions is a versatile tool that can automate almost any aspect of your development workflow. By understanding the key concepts and keywords, you can start creating powerful workflows tailored to your project’s needs. Start small, experiment, and gradually build more complex workflows as you become more comfortable with the platform.</p><p>Happy automating! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=901386afbf58" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding npm install, yarn install, and the Role of package-lock.json & yarn.lock]]></title>
            <link>https://medium.com/@narenprasanth.dev/understanding-npm-install-yarn-install-and-the-role-of-package-lock-json-yarn-lock-c281ff14ce84?source=rss-2cfe37e1c3cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/c281ff14ce84</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[backend-development]]></category>
            <dc:creator><![CDATA[Naren]]></dc:creator>
            <pubDate>Fri, 31 Jan 2025 10:46:46 GMT</pubDate>
            <atom:updated>2025-02-03T09:11:36.850Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is a Package Manager?</h3><p>A <strong>package manager</strong> is a tool that helps you install, update, and manage external libraries (called <strong>packages</strong>) that your project depends on. For example, if you want to use a library like lodash or react, you don’t need to manually download and include it in your project. Instead, you can use a package manager to do it for you.</p><p>The two most popular package managers in the JavaScript world are:</p><ol><li><strong>npm</strong> (Node Package Manager) — Comes pre-installed with Node.js.</li><li><strong>Yarn</strong> — Created by Facebook as a faster and more reliable alternative to npm.</li></ol><h3>How Does npm install Work?</h3><p>When you run npm install, here’s what happens:</p><ol><li><strong>Reads </strong><strong>package.json</strong>:<br>The package.json file is like a shopping list for your project. It contains all the dependencies (packages) your project needs. For example:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tuoco60jBMGSHHhUJ4vU0w.png" /></figure><p>Here, lodash and react are the dependencies, and ^4.17.21 and ^17.0.2 are the version ranges.</p><p><strong>2.</strong> <strong>Downloads Packages</strong>:<br>npm looks at the package.json file and downloads all the listed packages from the <a href="https://www.npmjs.com/">npm registry</a>. These packages are stored in a folder called node_modules.</p><p><strong>3. Creates </strong><strong>package-lock.json</strong>:<br>After installing the packages, npm creates a package-lock.json file. This file locks down the exact versions of all the packages and their dependencies. For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bn6jqrEqkUlBvM2w87WJnA.png" /></figure><p>The package-lock.json ensures that everyone working on the project uses the <strong>exact same versions</strong> of the packages, avoiding conflicts.</p><h3>How Does yarn install Work?</h3><p>yarn install works similarly to npm install, but with a few differences:</p><ol><li><strong>Reads </strong><strong>package.json</strong>:<br>Just like npm, yarn reads the package.json file to figure out which packages to install.</li><li><strong>Downloads Packages</strong>:<br>Yarn downloads the packages and stores them in the node_modules folder. However, yarn is generally faster than npm because it caches packages locally and parallelizes downloads.</li><li><strong>Creates </strong><strong>yarn.lock</strong>:<br>Yarn creates a yarn.lock file instead of package-lock.json. This file serves the same purpose: it locks down the exact versions of all packages and their dependencies. For example:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dqr0-PvFvgD9GIJAhIcp9g.png" /></figure><p>The yarn.lock file ensures consistency across installations, just like package-lock.json.</p><h3>Why Are package-lock.json and yarn.lock Important?</h3><p>Imagine you’re working on a team project. Without a lock file, each team member might end up with slightly different versions of the same package. This can lead to bugs and inconsistencies. For example:</p><ul><li>You install lodash@4.17.21, but your teammate installs lodash@4.17.22.</li><li>The newer version might have changes that break your code.</li></ul><p>The lock files (package-lock.json and yarn.lock) solve this problem by ensuring that <strong>everyone uses the exact same versions</strong> of all packages.</p><h3>Key Differences Between npm and yarn</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vrRTfoj7MhBEVPpXjCzmdQ.png" /></figure><h3>Best Practices</h3><ol><li><strong>Commit Lock Files to Version Control (Git)</strong>:<br>Always commit package-lock.json or yarn.lock to your Git repository. This ensures that everyone on the team uses the same versions of packages.</li><li><strong>Use One Package Manager</strong>:<br>Stick to either npm or yarn for a project. Mixing them can lead to inconsistencies.</li><li><strong>Update Dependencies Carefully</strong>:<br>When updating packages, make sure to test your code thoroughly. Use commands like npm update or yarn upgrade to update dependencies.</li></ol><h3>Conclusion</h3><p>In summary:</p><ul><li>npm install and yarn install are used to install dependencies listed in package.json.</li><li>package-lock.json (for npm) and yarn.lock (for yarn) ensure that everyone uses the same versions of packages.</li><li>Both package managers have their strengths, so choose the one that works best for your project.</li></ul><p>By understanding these concepts, you’ll be able to manage dependencies in your JavaScript projects like a pro! Happy coding! 🚀</p><p><em>Feel free to leave a comment if you have any questions or need further clarification!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c281ff14ce84" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>