-
Notifications
You must be signed in to change notification settings - Fork 389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ERR_REQUIRE_ESM
on vite build
when using '@auth0/nextjs-auth0/edge'
#1752
Comments
same here on webpack Next.js
EDIT: setting funnily enough we run prod app with same config as this one and no error is present eg. |
I was also able to workaround the ERR_REQUIRE_ESM error by building panva/oauth4webapi as a commonjs module. See patch:
EDIT: error is no longer present with @awwong1/[email protected], @awwong1/[email protected] |
Checklist
can be reproduced in the nextjs-auth0 sample app(or N/A).Description
This issue arises when using
nextjs-auth0
with Vite and is not relevant to NextJS.When
import { initAuth0 } from '@auth0/nextjs-auth0/edge'
is encountered while usingvite
, the following error is thrown:When building:
Expected behaviour is that the edge variant of this library can be imported without error.
Reproduction
Minimal reproducible example: https://github.com/awwong1/auth0-sveltekit-edge-issue
git clone https://github.com/awwong1/auth0-sveltekit-edge-issue.git && cd auth0-sveltekit-edge-issue
npm i
.dev.vars
file containingAPP_URL
,AUTH0_SECRET
,AUTH0_DOMAIN
,AUTH0_CLIENT_ID
,AUTH0_CLIENT_SECRET
environment variableshttp://localhost:5173/api/auth/callback
to your Auth0 application allowed callback URLsnpm run dev
, observe thathttp://localhost:5173/api/auth/login
,http://localhost:5173/api/auth/callback
,http://localhost:5173/api/auth/me
,http://localhost:5173/api/auth/logout
all function appropriatelyinitAuth0
with/edge
variant , observe build/run errorsAdditional context
Addressing this issue would help unlock using Auth0 with Sveltekit in the server side rendered edge environment.
nextjs-auth0 version
3.5.0
Next.js version
14.2.3
node_modules/@next/env/package.json
,npm explain @next/env
Node.js version
v20.10.0
EDIT: might be a duplicate of #1714 also
oauth4webapi
explicitly states commonjs is out of scope for their library https://github.com/panva/oauth4webapi/#out-of-scopeThe text was updated successfully, but these errors were encountered: