VScode says "Property 'initialize' does not exist on type 'typeof" API Key Moralis [SOLVED]

It says it to all moralis properties.
I already installed Moralis Snippets and used “npm install moralis”.
What do I do?

I am also trying to follow and old tutorial, is it why its showing the error?

Please provide more reference to what you’re trying to achieve. Screenshot and the steps you’ve taken to install the packages. It will help us catch the error faster.


I was following the how to clone rarible on youtube, when I try to use the functions that moralis has it shows me this, every word with 3 dots under shows that error.

Hey @Francisco

Ignore this. It tells you this because web3 is not a standard window object property.

I did, but when I try to run the app (first time launching the server exactly as shown in the first tutorial of the how to clone rarible) instead of showing me what the tutorial shows (if it was runing properly) it tshows both buttons(the hide element isn’t working) and the buttons don’t work.
I though it was because of that problem.
Now I open the console and it says “Uncaught ReferenceError: require is not defined” on top of the application id.
What do I do?moralis error

Try to add to the top of your code:

const Moralis = require('moralis');

1 Like

now if I use “const Moralis = require(‘moralis’);” it shows the same erroe, but with out it, like I had before its working, but the same problem as before apear.

Try Moralis.Web3, if I remember correctly

On latest versions of the SDK for activating web3 you need to use window.web3 = await Moralis.enable();

Now I get “TypeError: Cannot read properties of undefined (reading ‘authenticate’)” on the try catch block in the code and


Basically the tutorial is to old and I need to read the docs and figure out right?
Do you guys intend to make another how to clone rarible or opensea in the future?
Thanks for the help here!

@Francisco

Tutorial is a bit outdated. Now function for login is Moralis.authenticate()


These are just warnings, ignore them :man_mechanic:

Please help I have the exact same issue with the exact same words “Moralis.initialize” I tried everything mentioned in this post but literally none worked.

Hi,
Can you post your entire code?

Moralis.initialize(“chsq9Snf5cP87ThamdobAZBUhoyWIdFuX5RVsRIP”);

    Moralis.serverURL = "https://bspz2lfp1lyx.bigmoralis.com:2053/server";

    

    let homepage = "http://127.0.0.1:5500/index.html";

    if (Moralis.User.current() == null && window.location.href != homepage) {

        document.querySelector('body').style.display = 'none';

        window.location.href = "index.html";

        console.log("Not so fast!");

    }



login = async () => {

   await Moralis.authenticate().then(async function (user) {

        console.log("logged in");

        user.set("name", document.getElementById('user-username').value);

        user.set("email", document.getElementById('user-email').value);

        await user.save();

        window.location.href = "Dashboard.html"})}

logout = async () => {

        await Moralis.User.logOut();

        window.location.href = "index.html"};

    if(document.querySelector('#btn-login')  != null){

        document.querySelector('#btn-login').onclick = login;}

    if (document.querySelector('#btn-logout')  != null){

        document.querySelector('#btn-logout').onclick = logout;}`Preformatted text`

I mean entire HTML + javascript code that you would expect to work.

"<!doctype html>

<meta charset="utf-8">

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

<meta name="description" content="">

<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">

<meta name="generator" content="Hugo 0.88.1">

<title>Login Component</title>

<link rel="canonical" href="https://getbootstrap.com/docs/5.1/examples/sign-in/">

<link href="css/bootstrap.min.css" rel="stylesheet">

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

<link rel="stylesheet" href="style.css">
<img class="mb-4" src="CryptoSimplified Pic.png" alt="" width="92" height="67">

<h1 class="h3 mb-3 fw-normal">Please sign in</h1>

<div class="form-floating">

  <input type="text" class="form-control" id="user-username" placeholder="BigMan450?">

  <label for="user-username">Username</label>

</div>

<div class="form-floating">

  <input type="email" class="form-control" id="user-email" placeholder="[email protected]">

  <label for="user-email">Email address</label> </div>

<button id="btn-login" class="w-100 btn btn-lg btn-primary" type="submit">Sign In</button>

<p class="mt-5 mb-3 text-muted">&copy; 2017–2021</p>
"Preformatted text

I don’t see in this HTML something like:

    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/web3.min.js"></script>
    <script src="https://unpkg.com/[email protected]/dist/moralis.js"></script>    

I have a similar issue. Followed a Moralis tutorial for a dApp that signs a user in, signs with MetaMask then showcases user’s blockchain activity. The blockchain info (transactions, balances, etc) won’t populate, and Moralis admin doesn’t show the username and email. Triple checked my code, have snippets, cdn, etc but I keep getting these errors