I keep getting this error "cannot read properties of undefined (reading 'WebSocketProvider')"

this is my code


const ethers = require('ethers')
const { BigNumber, utils } = ethers

const provider = new ethers.providers.WebSocketProvider(

1 Answer 1


What version of ethers.js you are using? Try downgrading your ethers to v5.4.0 and check if it's working.

You can find more details in this post EthersJS Listening to events with NodeJS Strange Errors


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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