Search code examples
node.jsnpmhardhatpnpm

`hardhat` support for `pnpm`


Trying to use hardhat via pnpm.

With command:

pnpm add -D @nomicfoundation/hardhat-toolbox

Get following error:

devDependencies:
+ @nomicfoundation/hardhat-toolbox 1.0.2

 WARN  Issues with peer dependencies found
.
├─┬ @nomicfoundation/hardhat-toolbox 1.0.2
│ ├── ✕ missing peer @ethersproject/abi@^5.4.7
│ ├── ✕ missing peer @ethersproject/providers@^5.4.7
│ ├── ✕ missing peer @nomicfoundation/hardhat-network-helpers@^1.0.0
│ ├── ✕ missing peer @nomicfoundation/hardhat-chai-matchers@^1.0.0
│ ├── ✕ missing peer @nomiclabs/hardhat-ethers@^2.0.0
│ ├── ✕ missing peer @nomiclabs/hardhat-etherscan@^3.0.0
│ ├── ✕ missing peer @types/chai@^4.2.0
│ ├── ✕ missing peer @types/mocha@^9.1.0
│ ├── ✕ missing peer @types/node@>=12.0.0
│ ├── ✕ missing peer @typechain/ethers-v5@^10.1.0
│ ├── ✕ missing peer @typechain/hardhat@^6.1.2
│ ├── ✕ missing peer chai@^4.2.0
│ ├── ✕ missing peer ethers@^5.4.7
│ ├── ✕ missing peer hardhat-gas-reporter@^1.0.8
│ ├── ✕ missing peer solidity-coverage@^0.7.21
│ ├── ✕ missing peer ts-node@>=8.0.0
│ ├── ✕ missing peer typechain@^8.1.0
│ └── ✕ missing peer typescript@>=4.5.0
└─┬ hardhat 2.11.1
  ├── ✕ missing peer ts-node@"*"
  └── ✕ missing peer typescript@"*"
Peer dependencies that should be installed:
  @ethersproject/abi@^5.4.7                        @types/mocha@^9.1.0                              
  @ethersproject/providers@^5.4.7                  @types/node@>=12.0.0                             
  @nomicfoundation/hardhat-chai-matchers@^1.0.0    chai@^4.2.0                                      
  @nomicfoundation/hardhat-network-helpers@^1.0.0  ethers@^5.4.7                                    
  @nomiclabs/hardhat-ethers@^2.0.0                 hardhat-gas-reporter@^1.0.8                      
  @nomiclabs/hardhat-etherscan@^3.0.0              solidity-coverage@^0.7.21                        
  @typechain/ethers-v5@^10.1.0                     ts-node@>=8.0.0                                  
  @typechain/hardhat@^6.1.2                        typechain@^8.1.0                                 
  @types/chai@^4.2.0                               typescript@>=4.5.0                               

Progress: resolved 294, reused 284, downloaded 0, added 1, done

I've seen several other packages that doesn't work with pnpm too before.

So, what's the reason cause such issue, is it pnpm or specific packages (e.g hardhat) responsible for such issue?

I really prefer to use pnpm, because it's much quicker than npm.


Solution

  • Try the command:

    pnpm config set auto-install-peers true
    

    After that, just repeat your command and it will automatically install all the dependencies.