DEV Community

Simon Mannes
Simon Mannes

Posted on • Originally published at mannes.tech on

2 2

How To Fix Merge Conflicts in yarn.lock and package-lock.json

Merge conflicts happen.

With lock files, this can happen if you have different packages (or package versions) installed than in the branch you want to merge.

Fixing the package.json definition may take some work, but in difficult cases you can work together with the colleague who made the changes in the other branch.

But the yarn.lockfile (or package-json.log)? Oh my..

It's so long and may have dozens of conflicts for every single conflict in package.json.

The thing is.. You don't need to fix those merge conflicts yourself.

It is a file that's generated. Not written by a human.

Fixing merge conflicts there is a simple three-step process:

# 1.
rm yarn.lock

# 2.
yarn

# 3. 
git add yarn.lock
Enter fullscreen mode Exit fullscreen mode

Replace yarn.lock with package-lock.json if you're using npm.

Make your developer life simpler. Don't edit machine-generated files by hand. Simply regenerate them.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more