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

Testing helper generateSessionCookie error: subpath './testing' is not defined by "exports" #1945

Open
6 tasks done
stevechanvii opened this issue Mar 6, 2025 · 4 comments
Labels
ack bug Something isn't working

Comments

@stevechanvii
Copy link

Checklist

Description

We are using PlayWrite and need to generate a session by generateSessionCookie, this function can be imported in other files but not in testing files, I got this error:
Error: Package subpath './testing' is not defined by "exports" in /Users/......./node_modules/@auth0/nextjs-auth0/package.json

Some other people also face same error: #1857

Reproduction

Follow this example https://github.com/auth0/nextjs-auth0/blob/main/EXAMPLES.md#generatesessioncookie in testing file

Additional context

No response

nextjs-auth0 version

4.0.2

Next.js version

15.1.6

Node.js version

22.13.0

@tusharpandey13
Copy link
Contributor

Thank you for reporting this issue. This is a bug in our exports configuration - the testing utilities aren't properly exposed in the package.json. We'll fix this in our next release.

The fix adds the proper exports configuration:

"exports": {
  "./testing": {
    "types": "./dist/testing/index.d.ts",
    "default": "./dist/testing/index.js"
  },
  // other existing exports
}

As a temporary workaround, you can use a direct import:

import { generateSessionCookie } from '@auth0/nextjs-auth0/dist/testing';

Please let us know if this solution works for your setup!

@tusharpandey13 tusharpandey13 added bug Something isn't working ack labels Mar 7, 2025
@brycenrogers
Copy link

brycenrogers commented Mar 7, 2025

Using a direct import appears to result in a similar error

Error: Package subpath './dist/testing' is not defined by "exports"

@stevechan-medi
Copy link

Using a direct import appears to result in a similar error

Error: Package subpath './dist/testing' is not defined by "exports"

Same error

@stevechan-medi
Copy link

stevechan-medi commented Mar 18, 2025

Hey @tusharpandey13 the temp solution not working as well, got error Error: Package subpath './dist/testing' is not defined by "exports"
And v4.1.0 still have original error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ack bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants