DEV Community

Jeremy Ikwuje for Monierate Engineering Blog

Posted on

4 1

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.

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (2)

Collapse
 
alexkubica profile image
Alex Kubica 🇮🇱

For me npm install --save-dev @nomicfoundation/hardhat-toolbox --force did the trick

Collapse
 
alexkubica profile image
Alex Kubica 🇮🇱

on second try --force messed up the ethers package versions
downgrading to toolbox's v2 did the trick, for real this time 😂
❯ npm install --save-dev @nomicfoundation/hardhat-toolbox@2

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay