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.

Oldest comments (0)

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git