Import error with Kinde TypeScript SDK in Next.js 14 project using PNPM
Hello everyone,
I've recently integrated the Kinde auth solution into my Next.js 14 project, utilizing the app directory structure. However, I'm encountering an import error that's proving to be quite a hurdle. The issue arises when I attempt to use the RegisterLink or LoginLink components from the Kinde TypeScript SDK, or when navigating to the login API endpoint directly via http://localhost:3000/api/auth/login?post_login_redirect_url=%2Fdashboard.
The error message is as follows:
This leads me to suspect there might be a dependency issue, especially since I'm using PNPM as my package manager. Has anyone else encountered this problem, or does anyone have insights on how to resolve this import error? Any guidance or suggestions would be greatly appreciated.
Thank you in advance for your help!
5 Replies
Hi @Paul Cailly ,
It seems like you're trying to use the LoginLink and RegisterLink components from the Kinde TypeScript SDK in a Next.js project. However, these components are actually part of the Kinde Next.js SDK, not the TypeScript SDK.
You should import them like this:
import {LoginLink, RegisterLink} from "@Kinde-oss/kinde-auth-nextjs/components";
Then you can use them in your components:
<LoginLink>Sign in</LoginLink>
<RegisterLink>Sign up</RegisterLink>
Regarding the error message you're seeing, it's possible that there's a compatibility issue with PNPM. Kinde's SDKs are tested with NPM and Yarn, so if you continue to see errors, you might want to try switching to one of those package managers.
I hope this helps! Let me know if you have any other questions.
I'm importing them from the right package:
I do replicate the issue server side with this code snippet:
switching to another package manager is not really a viable option for us as the project is part of a monorepo where we use PNPM
We haven't tried pnpm with the packages before, you can try configuring pnpm to work like npm, e.g. using node-linker=hoisted. Let us know how you go
@Andre @ Kinde Added a
.npmrc
file with:
removed node_modules folder and pnpm install again but I still have the same error
@quacksire
this is our package.json:
we only use the nextjs package from @kinde-ossSaw this online:
https://github.com/pnpm/pnpm/issues/4997#issuecomment-1225486902
Able to give it a go?
GitHub
ENOENT: no such file or directory, copyfile · Issue #4997 · pnpm/pn...
Also having this issue after upgrading to v7. I have no idea how to reproduce it though... it works again by nuking the whole store and re-downloading everything. ENOENT ENOENT: no such file or dir...