-
Notifications
You must be signed in to change notification settings - Fork 560
Closed
Labels
bugThis points to a verified bug in the codeThis points to a verified bug in the code
Description
Checklist
- I have looked into the Readme and Examples, 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'm currently working on a React application using vitejs framework and I want use auth0-lock for authenticating users. But when I import Auth0Lock or Auth0LockPasswordless from "auth0-lock", I'm getting this error TypeError: Super expression must either be null or a function.
React: v18.2.0
Vite: v5.2.0
auth0-lock: v12.4.0
Searched issues: I've checked #1257 but that doesn't seem to be my problem/solution
Searched community: Couldn't find any solutions for this issue
It's throwing error on initial loading itself. I'm sharing my code and error below:
My code:
import { Auth0LockPasswordless } from "auth0-lock";
const Preview = () => {
return (
<div className="flex justify-between border-b-[2px] border-[#f0f0f0] p-6">
<h1 className="text-black text-xl font-semibold">Preview</h1>
<button
onClick={() => {
const lock = new Auth0LockPasswordless("clientId", "domain");
lock.show();
}}
className="bg-blue-500 text-white px-4 py-1 rounded"
>
Login
</button>
</div>
);
};
export default Preview;Full error:
Uncaught TypeError: Super expression must either be null or a function
at _inherits (auth0-lock.js?t=1713560656630&v=6df03345:34367:15)
at auth0-lock.js?t=1713560656630&v=6df03345:34431:7
at node_modules/auth0-lock/lib/core.js (auth0-lock.js?t=1713560656630&v=6df03345:34641:6)
at __require (chunk-B2BDBFHY.js?v=70481260:9:50)
at node_modules/auth0-lock/lib/lock.js (auth0-lock.js?t=1713560656630&v=6df03345:34681:41)
at __require (chunk-B2BDBFHY.js?v=70481260:9:50)
at node_modules/auth0-lock/lib/index.js (auth0-lock.js?t=1713560656630&v=6df03345:37581:40)
at __require (chunk-B2BDBFHY.js?v=70481260:9:50)
at auth0-lock.js?t=1713560656630&v=6df03345:37591:16
Reproduction
- Initialize react-vitejs application using the command
yarn create vite - Install
auth0-lockusing the commandyarn add auth0-lock - Import
Auth0LockPasswordlessin yourApp.jsxand initialize it. - Run the vite app using the command
yarn dev
React: v18.2.0
Vite: v5.2.0
auth0-lock: v12.4.0
Additional context
What I've tried:
- I googled and found this issue to be something related to named exports and I tried the following solution of adding "auth0-lock" alias in
vite.config.jsbut it didn't work.
resolve: {
alias: {
"auth0-lock": path.resolve(__dirname, './node_modules/auth0-lock/lib/index.js')
},
},- I tried using the
vite-plugin-commonjsand that also doesn't seem to work
// vite.config.js
import commonjs from "vite-plugin-commonjs";
export default defineConfig({
plugins: [commonjs()],My package.json
{
"name": "my-app",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"auth0-lock": "^12.4.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.19",
"eslint": "^8.57.0",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"postcss": "^8.4.38",
"tailwindcss": "^3.4.3",
"vite": "^5.2.0"
}
}Lock version
12.4.0
Which browsers have you tested in?
Chrome, Edge, Firefox
gianpesto, nameczz, Hworden and scott1702
Metadata
Metadata
Assignees
Labels
bugThis points to a verified bug in the codeThis points to a verified bug in the code