Unable to deploy NextJS Web3 Blockchain website

Hi Netlify Community,

I’ve been having issues with deploying my NextJS web3 blockchain site. It works great, locally but when i try to deploy it on netlify, I get the error: Type error: Property ‘ethereum’ does not exist on type ‘Window & typeof globalThis’. This is because I use the web3.js library in there like this:

if (typeof window !== "undefined") {
	if (window.ethereum) {	// THIS IS WHERE THE ERROR OCCURS
		web3Instance = new Web3(window.ethereum);
	} else if (window.web3) {

MY github repo link is here .

I wrote to netlify and I was redirected here.

Please anyone able to help me with this?

Thanks a lot!

Hi, @Chester. I just cloned your repo, ran npm install, and then npm run build. I get the same error:

$ npm run build

> decentragram@0.1.0 build
> next build

Attention: Next.js now collects completely anonymous telemetry regarding usage.
This information is used to shape Next.js' roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:

Failed to compile.

Type error: Property 'ethereum' does not exist on type 'Window & typeof globalThis'.

   8 |   // web3Instance = props.web3Instance;
   9 |   if (typeof window !== "undefined") {
> 10 |     if (window.ethereum) {
     |                ^
  11 |       // console.log("NEW OR MODERN BROWSER");
  12 |       web3Instance = new Web3(window.ethereum);
  13 |     } else if (window.web3) {
info  - Checking validity of types .

This was done on a system completely outside of Netlify. This is happening without using Netlify. This means Netlify isn’t causing the error. This is your code causing the error. Our support team doesn’t troubleshoot the code you write as that isn’t covered by the scope of our support.

This question is still welcome here and someone else might answer it. I just want to be clear that our support team cannot assist because the error isn’t caused by Netlify in any way.

Okay, thanks so much for the quick response and for all the help.

Yeah, I figured out the solution to the problem by just doing a simple google search; it’s a typescript error! Silly on my part to just think it was Netlify and not do any research on it first. I totally forgot to add ethereum as a ‘type’ to my react-app-env.d.ts file. Fixing that now. I’ll let the community know if it works.

Again, thanks for the help.

Chester B.

1 Like