[Ethereum] Hardhat Can’t resolve ‘console’ on react project

buidlermainnetweb3js

I have a react project and initialized hardhat config then installed the necessary packages but I am
getting error when I require hardhat on my project
const hre = require("hardhat");

This is error message when the project is compiling

./node_modules/@sentry/node/esm/integrations/console.js
Module not found: Can't resolve 'console' in 'C:\Users\sss\OneDrive\Desktop\my-react\node_modules\@sentry\node\esm\integrations'

How do I resolve this issue?

Best Answer

I was getting the same error and what fixed it for me was changing my imports statement for ethers from import { ethers } from 'hardhat'; to import { ethers } from 'ethers';