Solidity error: export 'ethers'.'providers' (imported as 'ethers') was not found in 'ethers' (possible exports:
The error seems small, but it can take you round solving many synptoms before you finally burn out and run out of the house.
It's simple, [email protected], the?providers?module has been moved to a separate package called?@ethersproject/providers. This means that you can't import?providers?directly from?ethers?anymore.
Let's solve this and move on to more challenges:
1. Install
npm install @ethersproject/providers
2. Choose provider
@ethersproject/providers?package doesn't have a default export called?providers. Instead, you need to import the specific provider you want to use then use it in your code.
In case you're using?Web3Provider?in your code as in the old days, you can try importing it like this:
import { Web3Provider as providers } from '@ethersproject/providers';
And then use it in your code like this:
const provider = new providers(window.ethereum);
From here your code will peacefully purr like a cat.
Reach out for more headaches anytime.