I can't get web3.js to work with Angular. I got the exact same problem as the person here.

I used method 2 from the answer on that question, and it seems to work as it now compiles, but I'm getting the following error in the console: screenshot of error

Basically all solutions on the internet on this problem that I have tried lead to this error for me.

How do I fix this?


Problem had to do with an initialization of the Contract class from web3 like this:

new Contract([]);

Even though vscode says that it clearly needs at least one parameter in the constructor, it caused this error. I fixed it by setting it to null instead (this is about setting the initialState in redux).

I still don't understand why this issue occurs, as Contract needs parameters in the constructor, so if someone knows, please tell.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.