NPM Err: Unable to resolve dependencies

178 Views Asked by At

I am building this web app that will allow a user to chat with their pdf. I am using pinecone as the vector database and also using langchain. So I npm installed pinecone before langchain but when it came to installing langchain I got an error about peer dependency issues between the two packages.

The error indicates that there is a conflict between the required version of @pinecone-database/pinecone in the @langchain/community package ("^1.1.0") and the version found in the root project ("^2.0.1"). Typically this error has been consistently present at the very last minute whenever I tried installing any dependency from that point on and results in failure to properly install them.

here:

npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve npm ERR! npm ERR! While resolving: @langchain/[email protected] npm ERR! Found: @pinecone-database/[email protected] npm ERR! node_modules/@pinecone-database/pinecone npm ERR! @pinecone-database/pinecone@"^2.0.1" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peerOptional @pinecone-database/pinecone@"^1.1.0" from @langchain/[email protected] npm ERR! node_modules/@langchain/community npm ERR! @langchain/community@"~0.0.17" from [email protected] npm ERR! node_modules/langchain npm ERR! langchain@"^0.1.4" from the root project npm ERR! @langchain/community@"^0.0.19" from the root project npm ERR! npm ERR! Conflicting peer dependency: @pinecone-database/[email protected] npm ERR! node_modules/@pinecone-database/pinecone npm ERR! peerOptional @pinecone-database/pinecone@"^1.1.0" from @langchain/[email protected] npm ERR! node_modules/@langchain/community npm ERR! @langchain/community@"~0.0.17" from [email protected] npm ERR! node_modules/langchain npm ERR! langchain@"^0.1.4" from the root project npm ERR! @langchain/community@"^0.0.19" from the root project npm ERR! npm ERR! Fix the upstream dependency conflict, or retry npm ERR! this command with --force or --legacy-peer-deps npm ERR! to accept an incorrect (and potentially broken) dependency resolution. npm ERR! npm ERR! npm ERR! For a full report see: npm ERR! C:\Users\Admin\AppData\Local\npm-cache_logs\2024-01-22T07_42_33_360Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in: C:\Users\Admin\AppData\Local\npm-cache_logs\2024-01-22T07_42_33_360Z-debug-0.log

To solve this issue, I previously flagged them using --legacy-peer-deps flag and that allowed me to install any package along the way.

I also attempted to update the packages using the command 'npm update'

However, whenever I needed to run a command that starts with npx, like for example npx shadcn-ui@latest add tooltip, the component won't be installed because npx doesn't recognize the --legacy-peer-deps flag and neither the --force flag as well.

I have tried looking for solutions everywhere including the langchain documentation but none has helped solve this issue so far.

1

There are 1 best solutions below

1
fhswno On

Had the same issue, and here's how I solved it:

Downgrading the version of pinecone doesn't help - it will most likely "break" it, and you will get a PineconeConnectionError. Using --force or --legacy-peer-deps are not sustainable options as you will need to use npx.

Langchain is still a young project and changes quite rapidly. In their documentation, they clearly explain that Langchain should be installed using npm install -S langchain and that @langchain/community is now automatically included as part of the initial langchain install, in langchain/core. If you get both langchain AND @langchain/community, this will trigger the dependency conflict.

TO FIX:

  1. Remove all references to langchain/community using npm uninstall + delete occurences of this package in package.json - only keep the langchain package.
  2. Delete your node_modules, package-lock.jsonand npm cache clean
  3. Run npm install

Your app will be running fine after, without having to --force or --legacy-peer-deps all your commands. If you read the documentation, you would see that all your Langchain imports can be made from the langchain package.