safe-core-sdk
safe-core-sdk copied to clipboard
[safe-contracts conflict] npm fails to install dependencies
Description
safe-contracts v1.4.1
has a fixed dependency ethers v5.4.0
. This makes impossible to install dependencies using npm as it conflicts with the SDK necessary dependency, at the time of writing ethers v5.7.2
and in few days ethers v6
Cloning the repo from Github and running:
npm i
returns the following error:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: @safe-global/[email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/ethers
npm ERR! dev ethers@"5.7.2" from @safe-global/[email protected]
npm ERR! packages/protocol-kit
npm ERR! @safe-global/[email protected]
npm ERR! node_modules/@safe-global/protocol-kit
npm ERR! workspace packages/protocol-kit from the root project
npm ERR! 5 more (@safe-global/account-abstraction-kit-poc, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer ethers@"5.4.0" from @safe-global/[email protected]
npm ERR! node_modules/@safe-global/safe-contracts-v1.4.1
npm ERR! dev @safe-global/safe-contracts-v1.4.1@"npm:@safe-global/[email protected]" from @safe-global/[email protected]
npm ERR! packages/protocol-kit
npm ERR! @safe-global/[email protected]
npm ERR! node_modules/@safe-global/protocol-kit
npm ERR! workspace packages/protocol-kit from the root project
npm ERR! 5 more (@safe-global/account-abstraction-kit-poc, ...)
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! /Users/<user>/.npm/_logs/2023-08-02T15_24_40_733Z-eresolve-report.txt
npm ERR! A complete log of this run can be found in: /Users/<user>/.npm/_logs/2023-08-02T15_24_40_733Z-debug-0.log
Solution
Remove npm import for safe-contracts v1.4.1
and manually add the contracts to the SDK repository, the same way contracts prior to v1.2.0
were added
This is due to NPM v7+ installing peerDependencies by default. This is not the case with previous versions NPM
[email protected]
has a peer using ethers 5.4.0. This should be addressed there for avoiding workarounds. Anyway you can do this:
- npm install --legacy-peer-deps
- npm install --force
Or we can 3) Forcing resolution to 5.7.2 => @dasanra ?
I was also checking this issue. Forcing resolution to v5.7.2 won't work. Also it's probably going to add issues when we migrate to ethers v6.
Original issue here may be adding safe-contracts
with all versions as dependencies of the protocol-kit
when we only need the contracts for type generation. This adds plenty of dependencies that are becoming outdated to the project and will create more problems specially trying to support more than one package manager.