【问题标题】:Namespace 'ReCaptcha' has no exported member X命名空间“ReCaptcha”没有导出的成员 X
【发布时间】:2022-01-25 21:29:11
【问题描述】:

我正在尝试在我的 Angular 应用程序中使用 ReCaptcha,不幸的是,在导入 ReCaptcha 模块后出现以下错误。

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>; ...
      

我已经使用npm install ng-recaptcha --save 将recaptcha 模块添加到我的角度项目中,并使用import { RecaptchaModule} from 'ng-recaptcha'; 将它导入到我的app.module.ts 中

使用过的版本: 节点:14.15.4 npm:6.14.10 ng-recaptcha: 9.0

在苹果 m1 芯片上运行

【问题讨论】:

  • 在您遇到此错误的地方分享您的代码,以便我可以为您提供适当的帮助
  • 请提供足够的代码,以便其他人更好地理解或重现问题。

标签: node.js angular typescript node-modules recaptcha


【解决方案1】:

在这种情况下,您需要升级您的 Angular 或降级您的 recaptcha。使用 npm i ngx-captcha@9.0.1,它是使用 Angular 6 及更高版本实现的。并按照此视频中的说明进行操作https://www.youtube.com/watch?v=AYznH6MBXM8

【讨论】:

    【解决方案2】:

    我正在使用angular 11,我降级了我的recaptcha 版本并且它有效。 尝试在 JSON 包上替换为 ng-recaptcha": "8.0.1,然后运行 ​​npm install

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-13
      • 2018-03-16
      • 2021-06-05
      • 2021-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多