TypeError when calling web3auth.connect() using @web3auth/node-sdk

Hi Loic — thanks for the clear report. I see you’re using MetaMask Embedded Wallets (Web3Auth) on Node.js with @web3auth/node-sdk ^5.0.0 and @web3auth/base ^9.7.0 and you hit a TypeError when calling web3auth.connect(). I’ll help narrow this down so the support team can jump in quickly.

What I pulled from your message

  • SDK: MetaMask Embedded Wallets (Web3Auth)
  • Platform: Node.js
  • Packages/versions: @web3auth/node-sdk ^5.0.0, @web3auth/base ^9.7.0
  • Issue: TypeError on web3auth.connect()
  • You linked code in PrivateBin (index.js, dotenv.js, payment.js)

Quick troubleshooting checklist (try these first):

  1. Call order: make sure you call await web3auth.init() and finish adapter setup before calling web3auth.connect(). Calling connect() before init() can produce TypeErrors.
  2. Environment: are you running the interactive login flow in a pure server (headless) Node environment? The client connect() flow opens a browser popup/redirect and won’t work server-side. If you’re on the server, use the node-sdk server flows or the client/browser SDK instead.
  3. Import/instantiation: confirm you’re importing/constructing correctly for your module system. Example patterns:
    • ESM: import { Web3Auth } from “@web3auth/node-sdk”;
    • CJS: const { Web3Auth } = require(“@web3auth/node-sdk”);
      Then: const web3auth = new Web3Auth({ clientId: “YOUR_CLIENT_ID”, chainConfig: {…} }); await web3auth.init();
  4. Version mismatch: mismatched major versions between @web3auth/node-sdk and @web3auth/base can cause missing methods. Try aligning/upgrading both to the latest compatible versions.

If that doesn’t fix it, please provide the following (these will help the support team reproduce and fix the bug):

  • The exact error message and full stack trace (copy/paste from console)
  • The initialization + login snippet (the few lines that create Web3Auth, call init(), and then call connect()). You linked PrivateBin files — if those already contain the init/connect snippet, please confirm which file and the exact lines you expect to run connect() from.
  • Tell me whether this code runs in a browser context (client) or a server/CLI Node process
  • Node version and how you import packages (import vs require)

Helpful resources:

  • MetaMask docs and Builder Hub are good general references: https://docs.metamask.io and https://builder.metamask.io
  • If you want, paste the init/connect snippet here (or confirm which PrivateBin file/lines contain them) and the exact TypeError text and I’ll propose a targeted fix.

If you want, I can also review the linked PrivateBin files if you confirm that’s OK. Would you like me to look at them now, or paste the specific init/connect lines and the error text here?

Note: This response was generated by an AI bot and may require further verification. The MetaMask Community Team has tracked this issue and will be responding as soon as possible.

Additionally, we would recommend you to join our biweekly Office Hours to get this resolved even faster. MetaMask Developer Office Hours