[Archive] TypeError: Class extends value undefined is not a constructor or null at torusEvmAdapter.esm.f28111a1.js:32:2329

:classical_building: Archived Content from Web3Auth Community

This topic was originally posted by githubdiscussions on 9/6/2022.
This content has been migrated from our previous community forum to preserve valuable discussions.


When I run:

await web3auth_.initModal()

I am getting this error:

TypeError: Class extends value undefined is not a constructor or null
at torusEvmAdapter.esm.f28111a1.js:32:2329

This only occurs in production. In dev everthing is ok.

Printing out the web3auth_ object returns a "kTe" object with status = "not_ready". Whereas running in my localhost, the web3auth object is called "Web3Auth" with status = "ready".

I am using a vite + react setup

Code snippet:

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="useEffect(() => { const init = async () => { setIsLoggingIn(true) try { <pre><code> const web3auth_ = new Web3Auth({ clientId: 'BCra18FhoqHZBjima6njP0JKotW1lSDCyjdhcyuHpj8WO_0AbQ04_psVRM-5XV9DpUFYGRbct78l5JVN4qvskh0', chainConfig: { chainNamespace: 'eip155', chainId: '0x89', rpcTarget: &quot;https://polygon-rpc.com&quot;, // This is just a placeholder, I am actually using my own private RPC target (both results same) displayName: &quot;Polygon Mainnet&quot;, blockExplorer: &quot;https://polygonscan.com/&quot;, ticker: &quot;MATIC&quot;, tickerName: &quot;Matic&quot;, }, uiConfig: { appLogo: &quot;https://raw.githubusercontent.com/junhuang-ho/miscellaneous/64fc258aefb53d20b6e520aa44c7e5be2bf10b06/l3-t1-crop.svg&quot; }, authMode: 'DAPP', storageKey: 'session'//'local' });
        await web3auth_.initModal()     // &amp;lt;----------- FAILS HERE

        setWeb3Auth(web3auth_)
        setIsLoggingIn(false)

        const provider = await web3auth_.connect()


    } catch (error) {
        console.error(error);
    } 
};
    init()

}, [selectedChain]);"><pre class=“notranslate”><code class=“notranslate”>useEffect(() =&gt; {
const init = async () =&gt; {
setIsLoggingIn(true)
try {

        const web3auth_ = new Web3Auth({
            clientId: 'BCra18FhoqHZBjima6njP0JKotW1lSDCyjdhcyuHpj8WO_0AbQ04_psVRM-5XV9DpUFYGRbct78l5JVN4qvskh0',
            chainConfig: {
                chainNamespace: 'eip155',
                chainId: '0x89',
                rpcTarget: "https://polygon-rpc.com", // This is just a placeholder, I am actually using my own private RPC target (both results same)
                displayName: "Polygon Mainnet",
                blockExplorer: "https://polygonscan.com/",
                ticker: "MATIC",
                tickerName: "Matic",
            },
            uiConfig: { appLogo: "https://raw.githubusercontent.com/junhuang-ho/miscellaneous/64fc258aefb53d20b6e520aa44c7e5be2bf10b06/l3-t1-crop.svg" },
            authMode: 'DAPP',
            storageKey: 'session'//'local'
        });

        await web3auth_.initModal()     // &amp;lt;----------- FAILS HERE

        setWeb3Auth(web3auth_)
        setIsLoggingIn(false)

        const provider = await web3auth_.connect()


    } catch (error) {
        console.error(error);
    } 
};
    init()

}, [selectedChain]);
</code></pre>
<p></code></pre></div><br/> <br /> Originally posted by: <a href=‘https://github.com/junhuang-ho’>junhuang-ho</a><br/> <br /> Check the discussion at: <a href=‘TypeError: Class extends value undefined is not a constructor or null at torusEvmAdapter.esm.f28111a1.js:32:2329 · Web3Auth · Discussion #558 · GitHub’>https://github.com/orgs/Web3Auth/discussions/558&lt;/a&gt;&lt;/p&gt;

Solution: https://stackoverflow.com/a/73362233/19776131

I think it has to do with vite.
I dont want to close this yet as I am hoping there will be a more permanent solution that comes with the next update?



Originally posted by: junhuang-ho