Auth0 Home Blog Docs

An error occurred when fetching client data for Lock: https://



Hi everyone,

I’m using Auth0-lock to create an authentication dialog.I want to create an auth-lock object in a NodeJS file.When I used :

const {Auth0Lock} = require('auth0-lock');

var lock = new Auth0Lock( MyClientId, MyDomain);;

in my NodeJS file, I got the following error:

var parser = global.document.createElement(‘a’);
TypeError: Cannot read property ‘createElement’ of undefined

I defined a virtual dom element for it, using jsdom as follow:

const jsdom = require("jsdom");
const { JSDOM } = jsdom;
const dom = new JSDOM('<!DOCTYPE html><html><body.....</body></html>');

global.window = dom.window;
global.document = dom.window.document;
global.location = dom.window.document.location;

By this, the above error was fixed, but I got another error without showing me the auth0-lock authentication dialog.It is:

Error: An error occurred when fetching client data for Lock:[MyClientId].js

Searches showed me this error indicates that Lock could not connect to the Auth0 CDN to fetch client. But when I uses auth0 cdn link and create auth-lock dialog in a html file using script as follow:

<script src=""></script>
var lock = new Auth0Lock( MyClientId, MyDomain);;

it worked with the exact same “MyClientId” and showed me the dialog.

Would you please help me to fix this problem and display the dialog in my NodeJS file?