Error When Authenticating with Metamask [SOLVED]

I’m following the YouTube tutorial for authenticating users with metamask but getting an error.

Code:

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

    
</head>

<body>
	
	
	<button onclick="login()">Login with Metamask</button>

	<script>
        
		Moralis.initialize("hbLGi00XmJZOwrkmjGeYXLmPOxdgg4Bj2GyAA6Gx"); // Application id from moralis.io
		Moralis.serverURL = "https://fc7em77djryo.moralis.io:2053/server"; //Server url from moralis.io
	
		async function login(){
			console.log("login clicked");
			var user = await Moralis.Web3.authenticate();
			}
		
	
	</script>
  </body>
</html>

Error:

moralis.js:4497 Uncaught (in promise) Error: Non ethereum enabled browser
    at moralis.js:4497
    at tryCatch (moralis.js:24495)
    at Generator.invoke [as _invoke] (moralis.js:24725)
    at Generator.next (moralis.js:24550)
    at asyncGeneratorStep (moralis.js:23942)
    at _next (moralis.js:23964)
    at moralis.js:23971
    at new Promise (<anonymous>)
    at new Wrapper (moralis.js:26960)
    at moralis.js:23960

Tutorial Video: https://youtu.be/6BfOtYfwFBI

Did you install the MetaMask browser extension? I get the same error in my browsers that don’t have MetaMask installed (Non ethereum enabled browser).

1 Like

Try install metamask in your browser https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn

1 Like

Another cause of this error is not serving the html on localhost. See the Troubleshooting docs here:
https://docs.moralis.io/misc/troubleshooting#uncaught-in-promise-error-non-ethereum-enabled-browser

2 Likes