-
Notifications
You must be signed in to change notification settings - Fork 316
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, Examples, and FAQ and have not found a suitable solution or answer.
- I have looked into the API documentation 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
When importing 'auth0' in Vite, the following error occurs:
ReferenceError: module is not defined
at /home/brian/project/node_modules/.pnpm/auth0@3.4.0/node_modules/auth0/src/index.js:8:1
at instantiateModule (file:///home/brian/project/node_modules/.pnpm/vite@4.3.5/node_modules/vite/dist/node/chunks/dep-934dbc7c.js:54360:15)
Reproduction
- Vite project with
auth0
import { ManagementClient } from 'auth0'
Additional context
Vite requires valid esm modules, meaning commonjs modules cannot be imported.
The following must be used with nodejs for this to be valid ESM.
import { createRequire } from 'module'
const require = createRequire(import.meta.url)
require('./path/to/common-js-module.js')
Note that webpack & rollup imports are not valid esm but a temporary hybrid.
node-auth0 version
v3.4.0
Node.js version
20.1.0
Metadata
Metadata
Assignees
Labels
bugThis points to a verified bug in the codeThis points to a verified bug in the code