Open fvictorio opened 1 year ago
Does Hardhat support Pnpm's flat node_modules
layout (which puts peer dependencies in the virtual directory node_modules/.pnpm
?
Even with auto-install-peers
enabled, I cannot get Hardhat to compile code from an npm package (@sablier/v2-core
) that itself has a dependency and peer dependency on another npm package (@openzeppelin/contracts
). I am getting this error:
Error HH411: The library @openzeppelin/contracts, imported from @sablier/v2-core/src/types/Tokens.sol, is not installed. Try installing it using npm.
This is even if OpenZeppelin is listed both as a dependency and as a peer dependency in Sablier.
The problem seems to be that Hardhat does not look for dependencies in Pnpm's virtual store in node_modules/.pnpm
. I put together a repro on the pnpm-sablier-deps branch in my Hardhat template.
I can confirm that this bug occurs only with Pnpm. I spun up a Hardhat project using the configuration wizard, installed @sablier/v2-core
using npm (instead of pnpm), and then I was able to compile the OpenZeppelin code.
Thanks Paul, I noticed the same thing when looking into #4194. I opened https://github.com/NomicFoundation/hardhat/issues/4292 to track this specific issue.
Is there any updates or roadmap on that @fvictorio? I can confirm I am experiencing the same. We have moved to a monorepo (using Turborepo) with lukso-network/lsp-smart-contracts and I am encountering the same error message as @PaulRBerg
Even with the following pnpm configurations in .npmrc
.
auto-install-peers=true
link-workspace-packages=deep
prefer-workspace-packages=true
I would love to know when this is planned to be fixed.
This will require internal reworking our import resolution code, this is something we will take a look at for our next major version.
At the moment, Hardhat works pretty well with npm 7 or later, but it's not great for other package managers, especially when the Toolbox is involved:
In addition to this, our docs don't correctly reflect the fact that there are two yarns out there, nor they include pnpm. Maybe we can add a new tab for yarn berry and pnpm, or maybe there's another way to do this.
In any case, this is a tracking issue to, at least: