Search code examples
angularauth0

Changing Auth0Lock to Auth0-js


In my Angular4 project I am trying to migrate from auth0-lock to auth0-js. For that I created the AuthService class that you can see in the documentation and install the auth0-js package by doing

npm install --save auth0-js

But, when I run my app I get the following error:

ERROR TypeError: Cannot read property 'WebAuth' of undefined

If I download the example project that you can find in quick start I do not get this error, but I do not know what else I have to do.


Solution

  • I just saw this solution below and it works:

    import * as auth0 from 'auth0-js';

    https://stackoverflow.com/a/44160476/2975759

    Also you may want to install the Types. I had issues with my IDE not seeing the methods and properties of the Auth0 package.

    npm install @types/auth0-js --save-dev