Search code examples
node.jsangulartypescriptnode-modulesrecaptcha

Namespace 'ReCaptcha' has no exported member X


I am trying to use ReCaptcha in my Angular App, unfortunately I get the following errors after importing the ReCaptcha-module.

Error: node_modules/ng-recaptcha/lib/recaptcha-loader.service.d.ts:23:21 - error TS2694: Namespace '"/Users/ahmadafrakhteh/WebstormProjects/Influentic/node_modules/@angular/core/core"' has no exported member 'ɵɵFactoryDeclaration'.

23     static ɵfac: i0.ɵɵFactoryDeclaration<RecaptchaLoaderService, [null, { optional: true; }, { optional: true; }, { optional: true; }, { optional: true; }]>;
                       ~~~~~~~~~~~~~~~~~~~~
node_modules/ng-recaptcha/lib/recaptcha-loader.service.d.ts:24:22 - error TS2694: Namespace '"/Users/ahmadafrakhteh/WebstormProjects/Influentic/node_modules/@angular/core/core"' has no exported member 'ɵɵInjectableDeclaration'.

24     static ɵprov: i0.ɵɵInjectableDeclaration<RecaptchaLoaderService>;
                        ~~~~~~~~~~~~~~~~~~~~~~~
node_modules/ng-recaptcha/lib/recaptcha.component.d.ts:58:21 - error TS2694: Namespace '"/Users/ahmadafrakhteh/WebstormProjects/Influentic/node_modules/@angular/core/core"' has no exported member 'ɵɵFactoryDeclaration'.

58     static ɵfac: i0.ɵɵFactoryDeclaration<RecaptchaComponent, [null, null, null, { optional: true; }]>;
                       ~~~~~~~~~~~~~~~~~~~~
node_modules/ng-recaptcha/lib/recaptcha.component.d.ts:59:21 - error TS2694: Namespace '"/Users/ahmadafrakhteh/WebstormProjects/Influentic/node_modules/@angular/core/core"' has no exported member 'ɵɵComponentDeclaration'.

59     static ɵcmp: i0.ɵɵComponentDeclaration<RecaptchaComponent, "re-captcha", ["reCaptcha"], { "id": "id"; "siteKey": "siteKey"; "theme": "theme"; "type": "type"; "size": "size"; "tabIndex": "tabIndex"; "badge": "badge"; "errorMode": "errorMode"; }, { "resolved": "resolved"; "error": "error"; }, never, never>;
                       ~~~~~~~~~~~~~~~~~~~~~~
node_modules/ng-recaptcha/lib/recaptcha-common.module.d.ts:4:21 - error TS2694: Namespace '"/Users/ahmadafrakhteh/WebstormProjects/Influentic/node_modules/@angular/core/core"' has no exported member 'ɵɵFactoryDeclaration'.

4     static ɵfac: i0.ɵɵFactoryDeclaration<RecaptchaCommonModule, never>;
                      ~~~~~~~~~~~~~~~~~~~~
node_modules/ng-recaptcha/lib/recaptcha-common.module.d.ts:5:21 - error TS2694: Namespace '"/Users/ahmadafrakhteh/WebstormProjects/Influentic/node_modules/@angular/core/core"' has no exported member 'ɵɵNgModuleDeclaration'.

5     static ɵmod: i0.ɵɵNgModuleDeclaration<RecaptchaCommonModule, [typeof i1.RecaptchaComponent], never, [typeof i1.RecaptchaComponent]>;
                      ~~~~~~~~~~~~~~~~~~~~~
node_modules/ng-recaptcha/lib/recaptcha-common.module.d.ts:6:21 - error TS2694: Namespace '"/Users/ahmadafrakhteh/WebstormProjects/Influentic/node_modules/@angular/core/core"' has no exported member 'ɵɵInjectorDeclaration'.

6     static ɵinj: i0.ɵɵInjectorDeclaration<RecaptchaCommonModule>;
                      ~~~~~~~~~~~~~~~~~~~~~
node_modules/ng-recaptcha/lib/recaptcha.module.d.ts:5:21 - error TS2694: Namespace '"/Users/ahmadafrakhteh/WebstormProjects/Influentic/node_modules/@angular/core/core"' has no exported member 'ɵɵFactoryDeclaration'.

5     static ɵfac: i0.ɵɵFactoryDeclaration<RecaptchaModule, never>;
                      ~~~~~~~~~~~~~~~~~~~~
node_modules/ng-recaptcha/lib/recaptcha.module.d.ts:6:21 - error TS2694: Namespace '"/Users/ahmadafrakhteh/WebstormProjects/Influentic/node_modules/@angular/core/core"' has no exported member 'ɵɵNgModuleDeclaration'.

6     static ɵmod: i0.ɵɵNgModuleDeclaration<RecaptchaModule, never, [typeof i1.RecaptchaCommonModule], [typeof i2.RecaptchaComponent]>;
                      ~~~~~~~~~~~~~~~~~~~~~
node_modules/ng-recaptcha/lib/recaptcha.module.d.ts:7:21 - error TS2694: Namespace '"/Users/ahmadafrakhteh/WebstormProjects/Influentic/node_modules/@angular/core/core"' has no exported member 'ɵɵInjectorDeclaration'.

7     static ɵinj: i0.ɵɵInjectorDeclaration<RecaptchaModule>;
                      ~~~~~~~~~~~~~~~~~~~~~
node_modules/ng-recaptcha/lib/recaptcha-v3.module.d.ts:3:21 - error TS2694: Namespace '"/Users/ahmadafrakhteh/WebstormProjects/Influentic/node_modules/@angular/core/core"' has no exported member 'ɵɵFactoryDeclaration'.

3     static ɵfac: i0.ɵɵFactoryDeclaration<RecaptchaV3Module, never>;
                      ~~~~~~~~~~~~~~~~~~~~
node_modules/ng-recaptcha/lib/recaptcha-v3.module.d.ts:4:21 - error TS2694: Namespace '"/Users/ahmadafrakhteh/WebstormProjects/Influentic/node_modules/@angular/core/core"' has no exported member 'ɵɵNgModuleDeclaration'.

4     static ɵmod: i0.ɵɵNgModuleDeclaration<RecaptchaV3Module, never, never, never>;
                      ~~~~~~~~~~~~~~~~~~~~~
node_modules/ng-recaptcha/lib/recaptcha-v3.module.d.ts:5:21 - error TS2694: Namespace '"/Users/ahmadafrakhteh/WebstormProjects/Influentic/node_modules/@angular/core/core"' has no exported member 'ɵɵInjectorDeclaration'.

5     static ɵinj: i0.ɵɵInjectorDeclaration<RecaptchaV3Module>;
                      ~~~~~~~~~~~~~~~~~~~~~
node_modules/ng-recaptcha/lib/recaptcha-v3.service.d.ts:76:21 - error TS2694: Namespace '"/Users/ahmadafrakhteh/WebstormProjects/Influentic/node_modules/@angular/core/core"' has no exported member 'ɵɵFactoryDeclaration'.

76     static ɵfac: i0.ɵɵFactoryDeclaration<ReCaptchaV3Service, [null, null, null, { optional: true; }, { optional: true; }, { optional: true; }]>;
                       ~~~~~~~~~~~~~~~~~~~~
node_modules/ng-recaptcha/lib/recaptcha-v3.service.d.ts:77:22 - error TS2694: Namespace '"/Users/ahmadafrakhteh/WebstormProjects/Influentic/node_modules/@angular/core/core"' has no exported member 'ɵɵInjectableDeclaration'.

77     static ɵprov: i0.ɵɵInjectableDeclaration<ReCaptchaV3Service>;
                        ~~~~~~~~~~~~~~~~~~~~~~~
node_modules/ng-recaptcha/lib/recaptcha-value-accessor.directive.d.ts:16:21 - error TS2694: Namespace '"/Users/ahmadafrakhteh/WebstormProjects/Influentic/node_modules/@angular/core/core"' has no exported member 'ɵɵFactoryDeclaration'.

16     static ɵfac: i0.ɵɵFactoryDeclaration<RecaptchaValueAccessorDirective, never>;
                       ~~~~~~~~~~~~~~~~~~~~
node_modules/ng-recaptcha/lib/recaptcha-value-accessor.directive.d.ts:17:21 - error TS2694: Namespace '"/Users/ahmadafrakhteh/WebstormProjects/Influentic/node_modules/@angular/core/core"' has no exported member 'ɵɵDirectiveDeclaration'.

17     static ɵdir: i0.ɵɵDirectiveDeclaration<RecaptchaValueAccessorDirective, "re-captcha[formControlName],re-captcha[formControl],re-captcha[ngModel]", never, {}, {}, never>; ...
      

I have added the recaptcha-module to my angular project using npm install ng-recaptcha --save and imported it in my app.module.ts with import { RecaptchaModule} from 'ng-recaptcha';

Used versions: node: 14.15.4 npm: 6.14.10 ng-recaptcha: 9.0

running on apple m1 chip


Solution

  • In this case, you either need to upgrade your Angular or downgrade you recaptcha. use npm i ngx-captcha@9.0.1 which is implemented using Angular 6 and above. and follow the instructions given in this video https://www.youtube.com/watch?v=AYznH6MBXM8