auth0/auth0.js

"Compilation failed: Cannot use import statement outside a module"

Closed this issue · 1 comments

Checklist

  • The issue can be reproduced in the auth0-js sample app (or N/A).
  • I have looked into the Readme and Examples, and have not found a suitable solution or answer.
  • I have looked into the API documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Description

I am not 100% sure this is the right repo but im experiencing the issue with both react sdk and pure js. i have created a minimal reproduceable example provided below. I get the error in my auth0 logs and on the console of the browser. im not sure how to fix this.

Reproduction

<script src="https://cdn.auth0.com/js/auth0-spa-js/2.0/auth0-spa-js.production.js"></script> <script> auth0.createAuth0Client({ domain: '', clientId: '', audience: '' }).then(async auth0 => { await auth0.loginWithPopup() const accessToken = await auth0.getTokenSilently() window.document.body.innerText = `{ "Authorization": "Bearer ${accessToken}"}`; }) </script>

Additional context

I have two stacks that both started experiencing the issue at the same time. both are different os, node versions, and sdks. One of my stacks is react the other is pure js. this has become a blocker for me. I get stuck in a loop of failed to auth and the above error

auth0-js version

2.0&1.12

Which browsers have you tested in?

Chrome, Firefox, Other

This is the wrong repository.

The correct repository is https://github.com/auth0/auth0-spa-js.

Additionally, this code is wrong:

auth0.createAuth0Client({ domain: '', clientId: '', audience: '' })

and needs to be:

auth0.createAuth0Client({ domain: '', clientId: '', authorizationParams: { audience: '' } })

But that isnt going to solve the error you mentioned.

Given the error comes from the server-side, this isn't an error originating from the SDK. I recommend disabling all actions on Auth0 and try again.