React Error: You need to call Parse.initialize before using Parse

This is the stack trace:

import moralis from "moralis";

moralis.initialize(process.env.MORALIS_APPLICATION_ID);
moralis.serverURL = process.env.MORALIS_SERVER_URL;

// Constants
const TWITTER_HANDLE = '_buildspace';
const TWITTER_LINK = `https://twitter.com/${TWITTER_HANDLE}`;
const OPENSEA_LINK = '';
const TOTAL_MINT_COUNT = 50;

const initialUser = moralis.User.current();

Here is my Replit: https://replit.com/@realquadrant/nft-starter-repo-final#src/App.js

A working version:

import { Moralis } from "moralis";

const appId = "APP_ID";
const serverUrl = "SERVER_URL";

Moralis.initialize(appId);
Moralis.serverURL = serverUrl;

const getBalance = async () => {
  const options = {
    chain: "ropsten",
    address: "0x12aADAdd301d22c941DACF2cfa7A9e2019972F61"
  };
  const balances = await Moralis.Web3API.account.getTokenBalances(options);
  console.log("all token balances of a current user", balances);
};

export default function App() {
  return (
    <div className="App">
      <button onClick={getBalance}> getBalance </button>
      <br />
    </div>
  );
}

Not sure if this part works well for you:

moralis.initialize(process.env.MORALIS_APPLICATION_ID);
moralis.serverURL = process.env.MORALIS_SERVER_URL;

Thanks, I found that code from a Moralis repo here:

Let me give yours a try, thank you!

I still get an error:

I think that in this particular case you also have to install wallet connect.

I also get a cannot find ‘moralis’ error even though I have the package installed.

This is for a React app.

But wait a second. Why you don’t use react-moralis?