Error in production in vue, TypeError: Right-hand side of ‘instanceof’ is not callable

Sure @alex, I’ll try to do this as soon as possible.

Hi @degueba are you able to post it in Moralis Github SDK? I would like to track the issue.

Hi guys, I was going to post it in Moralis Github SDK, however I found a better way to solve the issue.

1 - You will remove react-moralis from your repository
2 - Add this line of code in your index.html

<!-- Moralis -->
    <script src="https://unpkg.com/[email protected]/dist/moralis.js"></script>
    <script>
      window.Moralis = Moralis;
    </script>
<!---->

3 - Now everything that you want to use from Moralis you should use this way:
window.Moralis.FUNCTION()

Such as the following to start the connection.

window.Moralis.start({
    serverUrl: SERVER_URL,
    appId: APP_ID,
  });

Thank you for this suggestion. I was able to get Moralis to play nice with SvelteKit in production following a similar approach in my app.html file.

I’ll also make a note that if anyone also wants window.Moralis to be fully typed, they still install the Moralis SDK from NPM, and then declare a global interface. In Sveltekit this is done in app.d.ts but I’m sure Vue and React follow a similar approach.

import type Moralis from 'moralis/types';

declare global {
  interface Window {
    Moralis: Moralis;
  }
}

I know the Moralis SDK is undergoing a revamp, so I do hope the team will consider fully supporting frameworks that are built around Vite so we don’t have to use these hacky workarounds.

1 Like

Hi!

Has there been any updates/fixes to this issue?
I’m getting the same “TypeError: Right-hand side of ‘instanceof’ is not callable” error when building a Vite+React App.
I would love to avoid going back to CRA, please.

Thanks!

There’s an issue opened regarding that https://github.com/MoralisWeb3/react-moralis/issues/228

Thanks. Just commented on the issue but it seems there are no proposed solutions yet besides the CDN workaround.

is there anyone get over it yet?

Can you make a new thread with more details please.

it relates to the current as well asl the current was not resolved so why do we need to create new thread?
Here is full log i got:

TypeError: Right-hand side of 'instanceof' is not callable
  at encode(../node_modules/react-moralis/lib/index.esm.js:13958:7)
  at default(../node_modules/react-moralis/lib/index.esm.js:14042:10)
  at run(../node_modules/react-moralis/lib/index.esm.js:92033:31)
  at run(../node_modules/react-moralis/lib/index.esm.js:91960:52)
  at call(../node_modules/react-moralis/lib/index.esm.js:98460:35)
  at tryCatch(../node_modules/react-moralis/lib/index.esm.js:8138:40)
  at _invoke(../node_modules/react-moralis/lib/index.esm.js:8369:22)
  at key(../node_modules/react-moralis/lib/index.esm.js:8194:21)
  at asyncGeneratorStep(../node_modules/react-moralis/lib/index.esm.js:8871:20)
  at _next(../node_modules/react-moralis/lib/index.esm.js:8893:9)
  at ? (../node_modules/react-moralis/lib/index.esm.js:8900:7)
  at new Promise(<anonymous>)

Are you using Vue/Vite like the original issue? We need more info e.g. your project’s dependencies.

I’m using react, i think both are the same, there is an issue at https://github.com/MoralisWeb3/react-moralis/issues/228

My current dependencies:

"moralis": "^1.11.0",
"react-moralis": "^1.4.0",
"@web3auth/web3auth": "^1.1.4",
"@walletconnect/web3-provider": "^1.8.0",
1 Like

just tried again, it still happen on local running

I’m having the same issue after updating the moralis-v1 library.
I’m using react/next.js and typescript btw.

In case if you are using latest react moralis package, please change the package version to 1.4.0 for temporary fix

[email protected]

2 Likes

Happens to me too, with next, react-moralis 1.4.1

You could try with the previous version

Did you sort it out, even me has same dependencies and even shows me the same error

This happens in Next.js without web3uikit.

These package versions result in the error:

"moralis-v1": "1.11.0",
"next": "12.2.5",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-moralis": "1.4.1"

Reverting back to this resolves it:

"moralis": "1.11.0",
"next": "12.2.5",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-moralis": "1.4.0"
1 Like