DEV Community 👩‍💻👨‍💻

Jeremy Ikwuje for Forward School Africa

Posted on

Fix: Cannot find module '@nomicfoundation/hardhat-toolbox' Solidity

When you are trying to compile a Solidity contract with npx hardhat compile you may experience getting the error Cannot find module '@nomicfoundation/hardhat-toolbox'.

To fix the error "Cannot find module '@nomicfoundation/hardhat-toolbox'", ensure you install the package by running npm install --save-dev @nomicfoundation/hardhat-toolbox on your project terminal. If an error persist (probably due to dependencies) then install all packages required by the plugin. You can also use yarn to install it.

Open your terminal and install Hardhat Toolbox by running the following command:

npm install --save-dev @nomicfoundation/hardhat-toolbox
Enter fullscreen mode Exit fullscreen mode

If the "Cannot find module '@nomicfoundation/hardhat-toolbox" error is not resolved, try installing all dependencies.

Run the following command to install all dependencies:

npm install --save-dev @nomicfoundation/hardhat-toolbox @nomicfoundation/hardhat-network-helpers @nomicfoundation/hardhat-chai-matchers @nomiclabs/hardhat-ethers @nomiclabs/hardhat-etherscan chai ethers hardhat-gas-reporter solidity-coverage @typechain/hardhat typechain @typechain/ethers-v5 @ethersproject/abi @ethersproject/providers
Enter fullscreen mode Exit fullscreen mode

If you prefer to use yarn, the following command will also install all dependencies:

yarn add --dev @nomicfoundation/hardhat-toolbox @nomicfoundation/hardhat-network-helpers @nomicfoundation/hardhat-chai-matchers @nomiclabs/hardhat-ethers @nomiclabs/hardhat-etherscan chai ethers hardhat-gas-reporter solidity-coverage @typechain/hardhat typechain @typechain/ethers-v5 @ethersproject/abi @ethersproject/providers
Enter fullscreen mode Exit fullscreen mode

You can then go ahead compiling your Solidity smart contract.

Conclusion

As explained above, to fix the error "Cannot find module '@nomicfoundation/hardhat-toolbox'", ensure you install the package by running npm install --save-dev @nomicfoundation/hardhat-toolbox on your project terminal. If it still throws an error (probably due to dependencies) then install all packages required by the plugin. You can also use yarn to install all the dependencies.

Top comments (0)

Super Useful CSS Resources

A collection of 70 hand-picked, web-based tools which are actually useful.
Each will generate pure CSS without the need for JS or any external libraries.