[SOLVED] Uncaught ReferenceError: Moralis is not defined?

I have been getting the following error message in my browser console for a few hours now:

Uncaught ReferenceError: Moralis is not defined at app.js: 4

This is the code on app.js online 4:

Moralis.start({ serverUrl, appId });

The last time I posted about this error message, I was told it was due to a new version release.
Is this the case today?
When will it be fixed on your end?
Also is this going to be a recurring issue?

Can you share the cdn & unpkg url which you are using?

<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
<script src="https://unpkg.com/moralis/dist/moralis.js"></script>

Try updating unpkg this with

<script src="https://unpkg.com/moralis@latest/dist/moralis.js"></script>
1 Like

Updating the unpkg didn’t make a difference, am still getting the same error message.

If you got more than 1 html file, make sure you have the script in all.

Your script orders too really matters

My app is on a single HTML page.

Excluding the .CSS files, following are the .js script order:

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="js/jquery.toolbar.js"></script>
<script src="js/app.js"></script>

<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
<script src="https://unpkg.com/moralis@latest/dist/moralis.js"></script>

<script src="js/jquery-migrate-3.0.1.min.js+popper.min.js+bootstrap.min.js.pagespeed.jc.ln39gZSjGk.js"></script>

<script src="js/jquery.easing.1.3.js+jquery.waypoints.min.js+jquery.stellar.min.js+owl.carousel.min.js.pagespeed.jc.AgoWNHbz_d.js"></script>

<script src="js/jquery.magnific-popup.min.js+aos.js+nouislider.min.js.pagespeed.jc.56veBMvk__.js"></script>

<script src="js/moment-with-locales.min.js"></script>
<script src="js/bootstrap-datetimepicker.min.js+main.js.pagespeed.jc.xPq9ftnF14.js"></script>

Are they in the correct order? If not how should re-arrange the order that they flow in?

If this is your app code, add it after unpkg script line. So it will run once the moralis script is loaded.

1 Like

Aahh… thanks!
This helped resolve the issue!

1 Like

i am having the same issue, it was working fine but from yesterday i am having this problem.

my html file

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="stylesheet" href="stile.css">

    <link rel="stylesheet"  href="p.min.css">

     <!-- INSTALL THE SDK and WEB3 -->

        <script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>  

        <script src="https://unpkg.com/moralis/dist/moralis.js"></script>

        <!-- / -->

       

    <title>Document</title>

</head>

<body id="body">

   

   <div><button id="logn">Connect</button></div>

   <div id="address"> </div>

   <p>Create event </p>

    <input type="text" placeholder="name" id="name">

    <div><input type="text" placeholder="date" id="date"></div>

    <div ><input type="text " placeholder="price" id="price"></div>

    <div ><input type="text " placeholder="id" id="id"></div>

    <div ><input type="text " placeholder="ticketCount" id="ticketCount"></div>

   

    <button type="submit" id="btn">confirm</button>

<div id="cont"></div>

<script src="main.js"></script>

</body>

</html>

Change here form moralis/dist to moralis-v1/dist

1 Like

thank you. it works now

1 Like