TypeChain icon indicating copy to clipboard operation
TypeChain copied to clipboard

Error: Couldn't find ethers-v5 (yarn workspaces)

Open smartcontracts opened this issue 3 years ago • 6 comments

I'm getting the following error on the latest version of typechain:

Error: Couldn't find ethers-v5. Tried loading: @typechain/ethers-v5, typechain-target-ethers-v5, /home/k/Projects/work/optimism/packages/contracts/ethers-v5.
Perhaps you forgot to install @typechain/ethers-v5?

This is happening within a yarn/lerna monorepo. It appears this is happening because the typechain package is being hoisted to the root level, but the @typechain/ethers-v5 package is not.

smartcontracts avatar Feb 08 '22 01:02 smartcontracts

I had this too. It went away when I bumped typechain from 5.2.0 to 7.0.0 but that was probably just luck.

aspiers avatar Feb 13 '22 00:02 aspiers

Turns out it was just luck indeed. The issue randomly reappeared later even after upgrading to 7.0.0. After much trial and error, the only thing which fixed it for me was:

"nohoist": [
  "**/typechain",
  "**/@typechain/*"
]

aspiers avatar Feb 15 '22 20:02 aspiers

@smartcontracts does @aspiers fix work for you? yarn monorepos can be a mess...

krzkaczor avatar Feb 27 '22 22:02 krzkaczor

I'll give this fix a shot tomorrow and report back to you!

smartcontracts avatar Feb 27 '22 22:02 smartcontracts

@smartcontracts let me know. Also if you have a PR that I can look at that it could make debugging easier.

My bet would be that yarn decided to spread dependencies into a different tree after the upgrade and that's why it doesn't work now (note that waffle has a dependency on the old typechain version which make also affect your case).

krzkaczor avatar Feb 27 '22 22:02 krzkaczor

Just FYI, I've made target resolution more robust in the new version, so this should (no guarantees) be solved after the release.

hasparus avatar Mar 18 '22 15:03 hasparus