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

NextJS 13 Turbopack Error #882

Closed
7 tasks done
Jared-Dev opened this issue Oct 26, 2022 · 5 comments
Closed
7 tasks done

NextJS 13 Turbopack Error #882

Jared-Dev opened this issue Oct 26, 2022 · 5 comments
Labels
needs investigation This needs to be investigated further before proceeding

Comments

@Jared-Dev
Copy link

Checklist

  • The issue can be reproduced in the sample app (or N/A).
  • I have looked into the README and have not found a suitable solution or answer.
  • I have looked into the examples 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 using NextJS 13's Turbopack compiler I get the following error.

error - [resolve] [project-with-next]/node_modules/keyv/src/index.js  Error resolving commonjs request
  unable to resolve module "@keyv/redis" or module "@keyv/mongo" or module "@keyv/sqlite" or module "@keyv/postgres" or module "@keyv/mysql" or module "@keyv/etcd" or module "@keyv/offline" or module "@keyv/tiered" or dynamic
  
  | It was not possible to find the requested file.
  | Parsed request as written in source code: module "@keyv/redis" or module "@keyv/mongo" or module "@keyv/sqlite" or module "@keyv/postgres" or module "@keyv/mysql" or module "@keyv/etcd" or module "@keyv/offline" or module "@keyv/tiered" or dynamic
  | Path where resolving has started: [project-with-next]/node_modules/keyv/src/index.js
  | Type of request: commonjs request

The output from npm explain keyv indicates that the package in question is a dependency being pulled in from auth0's Next library.

keyv@4.5.0
node_modules/keyv
  keyv@"*" from @types/keyv@4.2.0
  node_modules/@types/keyv
    @types/keyv@"*" from @types/cacheable-request@6.0.2
    node_modules/@types/cacheable-request
      @types/cacheable-request@"^6.0.1" from got@11.8.5
      node_modules/got
        got@"^11.8.0" from openid-client@4.9.1
        node_modules/openid-client
          openid-client@"^4.9.1" from @auth0/nextjs-auth0@1.9.2
          node_modules/@auth0/nextjs-auth0
            @auth0/nextjs-auth0@"^1.9.2" from the root project
  keyv@"^4.0.0" from cacheable-request@7.0.2
  node_modules/cacheable-request
    cacheable-request@"^7.0.2" from got@11.8.5
    node_modules/got
      got@"^11.8.0" from openid-client@4.9.1
      node_modules/openid-client
        openid-client@"^4.9.1" from @auth0/nextjs-auth0@1.9.2
        node_modules/@auth0/nextjs-auth0
          @auth0/nextjs-auth0@"^1.9.2" from the root project

Reproduction

Start a Next13 project and configure Auth0's Next libary. Run next dev --turbo to enable the turbopack compiler.

SDK version

^1.9.2

Next.js version

13.0.0

Node.js version

lts/*

@adamjmcgrath
Copy link
Contributor

Thanks for raising this @Jared-Dev

Will see if there's something we can do to resolve this, but bear in mind that Turbopack is still in alpha

@adamjmcgrath adamjmcgrath added the needs investigation This needs to be investigated further before proceeding label Oct 27, 2022
@adamjmcgrath
Copy link
Contributor

@Jared-Dev - it looks like turbopack doesn't like the dynamic require in keyv here https://github.com/jaredwray/keyv/blob/2022-10-17/packages/keyv/src/index.js#L22

Since Turbopack supports dynamic require's - this looks like a bug in Turbopack (It looks related to vercel/turborepo#2349)

If I workaround this issue using the advice here jaredwray/keyv#45 (comment)

I run into another issue with turbopack's commonjs support here vercel/turborepo#2372

@Jared-Dev
Copy link
Author

@adamjmcgrath roger, mainly just making sure it is on the radar!

I knew this was a chance this was related to Turbopack being in alpha, but just in case the package wouldn't work for some reason I reported it. If nothing else it will give other users a point of reference!

@adamjmcgrath
Copy link
Contributor

Have upgraded openid-client (which was importing keyv via got) to the latest which doesn't use got anymore.

With the latest beta of nextjs-auth0 I can confirm that the sample application compiles successfully with 2.0.0-beta.2 running npm run dev --turbo on Next 13

@marcelomedina10
Copy link

marcelomedina10 commented Jul 4, 2023

I have this issue in my terminal with nextjs 13:

Import trace for requested module:
./node_modules/keyv/src/index.js
./node_modules/cacheable-request/src/index.js
./node_modules/got/dist/source/core/index.js
./node_modules/got/dist/source/create.js
./node_modules/got/dist/source/index.js
./node_modules/openid-client/lib/helpers/request.js
./node_modules/openid-client/lib/index.js
./node_modules/@auth0/nextjs-auth0/dist/auth0-session/transient-store.js
./node_modules/@auth0/nextjs-auth0/dist/auth0-session/index.js
./node_modules/@auth0/nextjs-auth0/dist/index.js
./app/(auth)/chat/page.js
- warn ./node_modules/keyv/src/index.js
Critical dependency: the request of a dependency is an expression

And i solved with this:

Have upgraded openid-client (which was importing keyv via got) to the latest which doesn't use got anymore.

With the latest beta of nextjs-auth0 I can confirm that the sample application compiles successfully with 2.0.0-beta.2 running npm run dev --turbo on Next 13

thanks @adamjmcgrath

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation This needs to be investigated further before proceeding
Projects
None yet
Development

No branches or pull requests

3 participants