0

I have a simple NodeJS file named index.js includes the following lines:

const {Auth0Lock} = require('auth0-lock');
var lock = new Auth0Lock( MyClientId,  MyDomain);    
lock.show();

I used npm install auth0-lock to install auth0lock and have the proper package.json file. When I run this piece of code by node index.js, I get the following error:

C:\Users\....\node_modules\auth0-lock\lib\utils\url_utils.js:6
var parser = global.document.createElement('a');
                           ^

TypeError: Cannot read property 'createElement' of undefined

Also, when I change const {Auth0Lock} = require('auth0-lock') to const Auth0Lock = require('auth0-lock'), I get the following error:

    var lock = new Auth0Lock(
           ^
    TypeError: Auth0Lock is not a constructor

Would you please help me to fix this error and have an auth0lock authentication dialog?

we.are
  • 409
  • 2
  • 6
  • 15

1 Answers1

0

If you are using auth0-lock with NodeJS you need to use a bundler like webpack or browserify.

Please refer to this repo: for setup configuration with webpack. Alternativel

surreal_sai
  • 101
  • 6