Getting ERESOLVE dependency conflict when upgrading langchain-related npm modules

I’m having trouble upgrading several langchain related packages in my project. The packages I’m working with include:

  • langchain
  • @langchain/community
  • langfuse-langchain
  • @langchain/openai
  • @langchain/google-genai
  • @google/generative-ai

Whenever I try to update these packages, I get this dependency resolution error:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/puppeteer
npm ERR!   peerOptional puppeteer@"^22.0.0" from @langchain/[email protected]
npm ERR!   node_modules/@langchain/community
npm ERR!     @langchain/community@"^0.2.21" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional puppeteer@"^19.7.2" from [email protected]
npm ERR! node_modules/langchain
npm ERR!   langchain@"^0.2.11" from the root project

It looks like there’s a version mismatch with puppeteer. After testing, I found that these three modules are causing the issue:

  • langchain
  • @langchain/community
  • langfuse-langchain

I’ve come across a couple potential fixes:

  1. Using --legacy-peer-deps flag during installation works but feels like a hack
  2. Deleting node_modules folder and package-lock.json file, though I’ve heard this isn’t recommended

Is there a proper way to resolve this conflict, or is using --legacy-peer-deps the best approach available right now?

Been fighting this puppeteer version mismatch for months across different projects. Langchain packages evolve so fast their peer dependencies constantly get out of sync.

Skip deleting node_modules or using legacy flags. Here’s what actually works:

Run npm list puppeteer to check your current version. You probably have a newer version that older langchain wants to downgrade. Don’t fight it - create a fresh package.json with exact versions that work together.

I keep this working combo in my notes: [email protected] with [email protected]. Upgrade langchain first to make it compatible with newer puppeteer versions. The community package usually catches up within a week or two.

If you’re not using puppeteer features (web scraping, PDF generation), exclude it entirely with npm install --omit=optional. Saves you from this whole mess.

This video covers dependency resolution patterns that apply here. Same principles work for any conflicting peer dependencies, not just Spring stuff.

Real talk - langchain’s dependency management is still messy. Keep your package-lock.json in version control so you can roll back when updates break things.

Had this same issue last month with my langchain setup. Different langchain packages want different puppeteer versions, so you get these peer dependency conflicts no matter what. Sure, --legacy-peer-deps works, but there’s a cleaner fix. Pin the puppeteer version in your package.json using overrides (npm) or resolutions (yarn): “overrides”: { “puppeteer”: “^22.14.0” }. This makes all packages use the same puppeteer version without needing the legacy flag. Been running this in production for weeks - no problems. The langchain ecosystem’s still sorting out versions, so these conflicts happen all the time. Just test your puppeteer stuff after adding the override to make sure everything still works.

Yeah, dependency hell with langchain packages is brutal right now. Don’t upgrade everything at once - do them one by one instead. Start with core langchain, then @langchain/community, then the rest. npm handles conflicts way better this way. Also check for newer versions since langchain moves crazy fast and newer releases usually fix these peer dependency nightmares. If you’re still stuck, temporarily ditch langfuse-langchain (it’s super picky about dependencies), update everything else, then add it back. Way more reliable than forcing installs with flags.

Dependency conflicts like this are exactly why I ditched manual npm version wrestling. Instead of juggling package versions or using hacky flags, I automated the whole langchain integration.

Set up a workflow that handles these dependencies automatically. When langchain packages update, it checks compatibility, tests everything, and only deploys if it all works. No more manual version pinning or --legacy-peer-deps hacks.

Built something like this for our AI pipeline last quarter. The system watches langchain releases, spins up test environments with different dependency combos, and finds working setups without me touching anything. Saves hours every week that used to go toward fixing broken builds.

Best part? You never think about puppeteer version mismatches again. The automation handles updates when they’re actually compatible, not just when they drop.

You can build this kind of dependency management automation easily with the right tools. Check out https://latenode.com