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

Module import error on Next 14.1.3 #290

Open
laurapadilla opened this issue Mar 20, 2024 · 2 comments
Open

Module import error on Next 14.1.3 #290

laurapadilla opened this issue Mar 20, 2024 · 2 comments

Comments

@laurapadilla
Copy link

laurapadilla commented Mar 20, 2024

react-google-recaptcha version: 2.1.9
node version: 18.18.2
next: 14.1.3
typescript: 4.9.5
macOS: Sonoma 14.4

I'm getting an Unable to resolve path to module 'react-google-recaptcha' error and I'm not exactly sure how to fix this. I have tried everything I can think of and I still get this error:

Screenshot 2024-03-20 at 11 47 25 AM

I'm also using Typescript, so I tried npm i @types/react-google-recaptcha, restarted the TS server, reloaded my IDE, and it still didn't solve the issue.

Any help would be appreciated!

@Miguelii
Copy link

Miguelii commented Apr 2, 2024

U can do a workaround for typescript. Create the file react-google-recaptcha.d.ts and inside put:

declare module 'react-google-recaptcha';

@frans-de-waal
Copy link

You could also manually declare the types for the component props:

declare module 'react-google-recaptcha' {
  export type ReCAPTCHAProps = {
    sitekey: string;
    onChange: (value: string) => void;
    onExpired: () => void;
    onErrored: () => void;
    size?: 'compact' | 'normal' | 'invisible';
    badge?: 'bottomright' | 'bottomleft' | 'inline';
    tabindex?: number;
    type?: 'image' | 'audio';
    theme?: 'light' | 'dark';
  } & React.ComponentPropsWithRef<'div'>;

  const ReCAPTCHA: React.FC<ReCAPTCHAProps>;

  export default ReCAPTCHA;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants