Skip to content
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

V4 Nextjs 15 pages router "Failed to load external module" on any import #1795

Closed
6 tasks done
MrSimmmons opened this issue Nov 10, 2024 · 6 comments
Closed
6 tasks done

Comments

@MrSimmmons
Copy link

Checklist

Description

Using the Nextjs v15 Pages Router with the V4 readme (up to step 4 is enough) will fail to load or build with the following error in browser
Screenshot 2024-11-10 at 11 06 55 PM

and in terminal
Screenshot 2024-11-10 at 11 07 13 PM


I am able to successfully get all the exports to work if i manually import the exact path to the folders index file (or directly to the file its self.
Screenshot 2024-11-10 at 11 11 53 PM

Screenshot 2024-11-10 at 11 11 38 PM

Reproduction

  1. Create a V15 Pages router project using the create next app CLI https://nextjs.org/docs/pages/api-reference/cli/create-next-app
  2. Follow the getting started guide provided in the V4 readme (up to Step 4 is enough)
  3. Start the app in dev mode (will break with both webpack and turbopack bundlers)

Additional context

VSCode IntelliSense still works on the import functions and classes. So I can still command click them and VSCode will take me to their type sources, and autocomplete still functions. However this is annoying in this sense because the autocompleted "path" is causing the error and I have to manually modify the path as shown above to address it.


I noticed that the provided App Router example works fine so it must be just an issue with the Pages Router


Having your code in a /src directory or not makes no difference


The directory that the import errors are completing about are correct import paths (aside from maybe the file extension being omitted in the error? That might be the only thing that looks slightly off to me) as I can put them into finder and go to the correct place.

nextjs-auth0 version

V4.0.0 beta 0

Next.js version

15.0.3

Node.js version

20.18.0

@guabu
Copy link

guabu commented Nov 11, 2024

Hi @MrSimmmons 👋 Thanks for reporting this! I've just pushed a fix — could I kindly ask you to upgrade to @auth0/nextjs-auth0@4.0.0-beta.2 and give it a try please?

@MrSimmmons
Copy link
Author

@guabu Hey thanks! it seems to have worked for the client side, but SSR pages & server actions still seem to be getting the same error
Screenshot 2024-11-12 at 10 46 51 AM

Im guessing that you will have to do the same .js file for all exports

@guabu
Copy link

guabu commented Nov 13, 2024

Hey @MrSimmmons 👋 We've been doing some investigation around this and it looks like there's a difference in how Next.js resolves & transpiles packages for App router vs Pages router.

The next release will include a fix for this. For the time being, you can add the following to your next.config.ts which should help resolve the issue temporarily:

transpilePackages: ["@auth0/nextjs-auth0"]

@MrSimmmons
Copy link
Author

Ah awesome that appears to be working now. Ill leave this ticket open and you can close it when the fix is merged
Thanks again!

@guabu guabu mentioned this issue Nov 13, 2024
@guabu
Copy link

guabu commented Nov 14, 2024

Hi @MrSimmmons 👋 We've cut a new release which addresses this issue. You should now be able to upgrade to the latest and revert any modifications from your next.config.ts: npm i @auth0/nextjs-auth0@4.0.0-beta.3

Thanks again for reporting this!

@MrSimmmons
Copy link
Author

MrSimmmons commented Nov 14, 2024

@guabu Awesome just tried it out. Works great thanks guys!

Just so y'all know there is another issue with the pages router that I reported over at #1801
TBH I'm not sure if its a Next 15 issue, or a v4 issue, but some clarification would be great since it is the recommended way for SSR pages according to the README

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants