Auth0 Home Blog Docs

AuthenticationClient is not a constructor


#1

I am attempting to migrate our platform from Auth0-Lock 10.x to Universal Login to move towards compliance with deprecations July 16th, 2018. Our stack is Node.js server and React client.

Previously, our Auth0 client-side Lock service looked something like this (package.json > “auth0-lock”: “^10.2.2”):

import Auth0Lock from ‘auth0-lock’

this.lock = new Auth0Lock(this.clientId, this.domain, lockCfg);

After our attempted migration, the Auth0 client service looks like (package.json > “auth0-js”: “^9.6.1”):

const AuthenticationClient = require(‘auth0’).AuthenticationClient;

var auth0Client = new AuthenticationClient({
domain: ${process.env.AUTH0_DOMAIN},
clientId: ${process.env.AUTH0_CLIENT_ID}
});

this.lock = new auth0Client.WebAuth({

This results in the following webpack builder error:

ERROR in ./src/utils/AuthService.js
Module not found: Error: Can’t resolve ‘auth0’ in ‘/Users/jacobmyers/projects/sumergeme2/src/utils’

I also tried changing the require(‘auth0’) statement to:
import * as auth0 from ‘auth0-js’
Then the build works, but i get the error:
AuthenticationClient is not a constructor

Please help me get this migration working! Thank you.


#2

A post was merged into an existing topic: Import auth0 issue - july 16 migration


#3