<?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 Hugo Dzin on Medium]]></title>
        <description><![CDATA[Stories by Hugo Dzin on Medium]]></description>
        <link>https://medium.com/@hugodzin?source=rss-bc605d2a117d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*mMKYhetUknfj6Gxp.</url>
            <title>Stories by Hugo Dzin on Medium</title>
            <link>https://medium.com/@hugodzin?source=rss-bc605d2a117d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 02:17:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hugodzin/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[Resolving Git Conflicts in package-lock.json]]></title>
            <link>https://medium.com/@hugodzin/resolving-git-conflicts-in-package-lock-json-25c0d52bc2f?source=rss-bc605d2a117d------2</link>
            <guid isPermaLink="false">https://medium.com/p/25c0d52bc2f</guid>
            <category><![CDATA[guides-and-tutorials]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Hugo Dzin]]></dc:creator>
            <pubDate>Mon, 14 Aug 2023 06:44:32 GMT</pubDate>
            <atom:updated>2023-08-14T06:44:32.985Z</atom:updated>
            <content:encoded><![CDATA[<p>Often when doing Git merges in Node.js projects, we end up with conflicts in package-lock.json or yarn.lock. This usually happens if both branches modified package.json or updated dependencies.</p><p>However, since those are generated files, it’s not feasible nor recommended to fix the conflicts manually. A simple way of resolving them is as follows:</p><pre>git checkout --theirs package-lock.json<br># If using yarn, instead do:<br># git checkout --theirs yarn.lock<br><br>npm install</pre><p>After that, as a sanity check, confirm that the project still builds and runs.</p><p>If you’re using Git in a graphic interface, such as GitKraken or VSCode, look open package-lock.json (or yarn.lock) in the conflict resolution window and look for a button labeled “Accept Theirs” or similar.</p><h3>What Does That Do?</h3><p>git checkout --theirs package-lock.jsoncopies the lockfile from the incoming (the “other”) branch. npm install updates it with the changes that your branch made to package.json.</p><h3>Why Bother Comitting package-lock.json?</h3><p>In conjunction with npm ci, it makes installing dependencies reproducible.</p><p>npm install can sometimes updates dependencies, which is usually not a problem, but may cause your deployment pipeline to fail if a dependency releases a broken update. For example, this happened with <a href="https://github.com/aws/aws-sdk-js-v3/issues/4060">aws-sdk</a> a while back, so if you had that dependency and weren&#39;t using npm ci, there&#39;s a good chance your pipeline broke at the time.</p><p>Having a lockfile commited and using npm ci instead of npm install in your deployment pipeline should protect you from this kind of problem.</p><p>If you’re using yarn, the equivalent to npm ci is yarn install --frozen-lockfile.</p><h3>Other Suggestions</h3><p>Avoid having more than one type of lockfile committed (for example, both package-lock.json and yarn.lock), and by extension avoid using multiple dependency managers in the same project. Discuss with your teammates which dependency manager you&#39;re all going to use, and only use that.</p><p>Use <a href="https://github.com/nvm-sh/nvm">NVM</a> or an alternative for managing multiple Node versions. This might come in handy if you have a project that only works with an older version of Node, but would like to use a more updated one the rest of the time.</p><p>For more future-proofing, consider documenting which version of Node the project is meant to work with. If using NVM, you can create an .npmrc file with the output from node -v, like so:</p><pre>v16.14.2</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=25c0d52bc2f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>