• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

268
Views
¿Qué está causando este error de exportación al intentar usar un proveedor de NextAuth.js con Next.js?

Estoy creando mi primer proyecto en React/Next.js, usando NextAuth.js para Auth-N. Estoy siguiendo vagamente la guía de introducción en el sitio web de NextAuth y he creado una página [...nextauth].js que contiene el siguiente código:

 import NextAuth from 'next-auth'; import GoogleProvider from 'next-auth/providers/google'; export default NextAuth({ providers: [ GoogleProvider({ clientId: process.env.GOOGLE_CLIENT_ID, clientSecret: process.env.GOOGLE_CLIENT_SECRET, }) ] })

Estoy usando el proveedor en una página Header.js que contiene el siguiente código:

 ... import {useSession, signIn, signOut} from 'next-auth/react'; const Header = () => { const { data: session } = useSession() ... return ( <header className="border-b border-gray-100 dark:border-gray-700"> <div className="container mx-auto px-4 sm:px-6 py-4 flex justify-between items-center"> <Logo /> <div className={"flex items-center space-x-1 sm:space-x-2"}> {!session ? ( <button type="button" onClick={() => signIn()} className="bg-blue-700 text-white px-4 py-2 rounded-md focus:outline-none focus:ring-4 focus:ring-blue-600 focus:ring-opacity-50 whitespace-nowrap">Sign in</button> ) : ( <button type="button" onClick={() => signOut()} className="bg-blue-700 text-white px-4 py-2 rounded-md focus:outline-none focus:ring-4 focus:ring-blue-600 focus:ring-opacity-50 whitespace-nowrap">Sign out</button> )} </div> </div> </header> ) }; export default Header;

Sin embargo, cuando abro mi sitio con 'npm run dev' e intento iniciar sesión, aparece el siguiente error:

 Server Error Error: Package subpath './providers/google' is not defined by "exports" in /Users/tysont/Workspace/brightnote/node_modules/next-auth/package.json

Estoy usando NextAuth 4.0.6 y no veo una exportación específica de /google mencionada en ninguna parte del paquete NextAuth.json localmente o en GitHub . ¿Debería haber? ¿Qué me estoy perdiendo?

almost 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

  1. Asegúrese de tener una versión de nodo compatible, estoy usando 12.22.1.
  2. Compruebe si el nombre del archivo [...nextauth].js está escrito correctamente.
almost 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error