blitz-js / blitz

⚡️ The Missing Fullstack Toolkit for Next.js
https://Blitzjs.com
MIT License
13.6k stars 794 forks source link

can't integrate social sign in #4370

Closed Vandivier closed 2 weeks ago

Vandivier commented 3 weeks ago

What is the problem?

When I wrap my Next.js config with withNextAuthAdapter as instructed, I see the following error on server startup (via npm run dev ie blitz dev):

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './core/init' is not defined by "exports" in /Users/johnvandivier/workspace/ladderly-3/node_modules/next-auth/package.json

Paste all your error logs here:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './core/init' is not defined by "exports" in /Users/johnvandivier/workspace/ladderly-3/node_modules/next-auth/package.json

Paste all relevant code snippets here:

n/a

What are detailed steps to reproduce this?

  1. set up new app
  2. install next-auth
  3. update next.config.js to use withNextAuthAdapter
  4. run server

Run blitz -v and paste the output here:

blitz -v
Blitz version: 2.0.9 (global)
Blitz version: 2.0.9 (local)
macOS Ventura | darwin-arm64 | Node: v20.15.0

 Package manager: npm

  System:
    OS: macOS 13.5.2
    CPU: (8) arm64 Apple M2
    Memory: 47.13 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.15.0 - ~/.nvm/versions/node/v20.15.0/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - ~/.nvm/versions/node/v20.15.0/bin/npm
  npmPackages:
    @blitzjs/auth: 2.0.9 => 2.0.9 
    @blitzjs/next: 2.0.9 => 2.0.9 
    @blitzjs/rpc: 2.0.9 => 2.0.9 
    @prisma/client: 5.4.2 => 5.4.2 
    blitz: 2.0.9 => 2.0.9 
    next: 14.2.3 => 14.2.3 
    prisma: 5.4.2 => 5.4.2 
    react: 18.2.0 => 18.2.0 
    react-dom: 18.2.0 => 18.2.0 
    typescript: ^4.8.4 => 4.9.5 

Please include below any other applicable logs and screenshots that show your problem:

some other useful dep versions:


    "@blitzjs/auth": "2.0.9",
    "@blitzjs/next": "2.0.9",
    "@blitzjs/rpc": "2.0.9",
    "@next-auth/prisma-adapter": "1.0.7",
Vandivier commented 3 weeks ago

related: https://www.youtube.com/live/gNwZlocrxnQ?si=VvXf-dMLirrLZmgC&t=2271 https://github.com/Vandivier/ladderly-3/pull/299

siddhsuresh commented 2 weeks ago

@Vandivier apologies about the delay in responding

There is no current way of getting next-auth working without a manual patch. I am working on checking for a fix, but more monkey patching will not be solution, until the next-auth team allows more internal exports

This patch or the exports in these files are needed for the social sign in to work.

diff --git a/package.json b/package.json
index c89e03c41a03de738cfb0ad090a63c2e99dadc7b..a5f38083c24732651c427c2b2d17cbcb23495473 100644
--- a/package.json
+++ b/package.json
@@ -57,6 +57,18 @@
     "./providers/*": {
       "types": "./providers/*.d.ts",
       "default": "./providers/*.js"
+    },
+    "./core/init": {
+      "types": "./core/init.d.ts",
+      "default": "./core/init.js"
+    },
+    "./core/lib/oauth/authorization-url": {
+      "types": "./core/lib/oauth/authorization-url.d.ts",
+      "default": "./core/lib/oauth/authorization-url.js"
+    },
+    "./core/lib/oauth/callback": {
+      "types": "./core/lib/oauth/callback.d.ts",
+      "default": "./core/lib/oauth/callback.js"
     }
   },
   "files": [