Angular directive required to implement GoogleSigninButtonDirective in @abacritt/[email protected] does not work for Angular 13
NickName:David Alberici Ask DateTime:2022-12-01T15:40:20

Angular directive required to implement GoogleSigninButtonDirective in @abacritt/[email protected] does not work for Angular 13

Although the library states that @abacritt/angularx-social-login:1 is compatible with Angular 13 and 14, it is not working for my Angular 13 project, this error is thrown after npm start, which seems to blame GoogleSigninButtonDirective for the error, and the reason being that it requires Angular 14:


./node_modules/@abacritt/angularx-social-login/fesm2015/abacritt-angularx-social-login.mjs - Error: Module build failed (from ./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js):    
TypeError: Cannot create property 'message' on string 'C:\Vidoqui\Repositories\vidoqui-frontend2\node_modules\@abacritt\angularx-social-login\fesm2015\abacritt-angularx-social-login.mjs: This application 
depends upon a library published using Angular version 14.2.0, which requires Angular version 14.0.0 or newer to work correctly.
Consider upgrading your application to use a more recent version of Angular.
  457 | }
  458 | GoogleSigninButtonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.0", ngImport: i0, type: GoogleSigninButtonDirective, deps: [{ token: i0.ElementRef }, { token: SocialAuthService }], target: i0.ɵɵFactoryTarget.Directive });
> 459 | GoogleSigninButtonDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.0", type: GoogleSigninButtonDirective, selector: "asl-google-signin-button", inputs: { type: "type", size: "size", text: "text", shape: "shape", theme: "theme", logo_alignment: "logo_alignment", width: "width", locale: "locale"9m }, ngImport: i0 });
      |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^[1m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^[1m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^[1m^^^^^^^^^^^^^^^
  460 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.0", ngImport: i0, type: GoogleSigninButtonDirective, decorators: [{
  461 |             type: Directive,
  462 |             args: [{'
    at run (C:\Vidoqui\Repositories\vidoqui-frontend2\node_modules\@babel\core\lib\transformation\index.js:37:15)
    at run.next (<anonymous>)
    at Function.transform (C:\Vidoqui\Repositories\vidoqui-frontend2\node_modules\@babel\core\lib\transform.js:25:41)
    at transform.next (<anonymous>)
    at step (C:\Vidoqui\Repositories\vidoqui-frontend2\node_modules\gensync\index.js:261:32)
    at C:\Vidoqui\Repositories\vidoqui-frontend2\node_modules\gensync\index.js:273:13
    at async.call.result.err.err (C:\Vidoqui\Repositories\vidoqui-frontend2\node_modules\gensync\index.js:223:11)
    at C:\Vidoqui\Repositories\vidoqui-frontend2\node_modules\gensync\index.js:37:40

Error: node_modules/@abacritt/angularx-social-login/directives/google-signin-button.directive.d.ts:15:18 - error TS2314: Generic type 'ɵɵDirectiveDeclaration' requires 6 type argument(s).

15     static ɵdir: i0.ɵɵDirectiveDeclaration<GoogleSigninButtonDirective, "asl-google-signin-button", never, { "type": "type"; "size": "size"; "text": "text"; "shape": "shape"; "theme": "theme"; "logo_alignment": "logo_alignment"; "width": "width"; "locale": "locale"; }, {}, never, never, false>;

A little more of context, I followed the documentation to install @abacritt/angularx-social-login:1, which requires the following:

  1. Adding the dependency with npm i @abacritt/angularx-social-login
  2. In AppModule, import the SocialLoginModule and add providers (in my case I just need the GoogleLoginProvider)
  3. Use <asl-google-signin-button type='icon' size='medium'></asl-google-signin-button> in the component template/html where I want the google button to show

Snippet of my AppModule


@NgModule({
  declarations: [
    ...
  ],
  imports: [
    ...
    SocialLoginModule
  ],
  providers: [
    {
      provide: 'SocialAuthServiceConfig',
      useValue: {
        autoLogin: false,
        providers: [
          {
            id: GoogleLoginProvider.PROVIDER_ID,
            provider: new GoogleLoginProvider(
              'clientId'
            )
          }
        ],
        onError: (err) => {
          console.error(err);
        }
      } as SocialAuthServiceConfig,
    }
  ],
  bootstrap: [...]
})

Snippet of my package.json

{
  "name": "xxxxxx",
  "version": "x.x.x",
  "scripts": {
    ...
  },
  "private": true,
  "dependencies": {
    "@abacritt/angularx-social-login": "^1.2.5",
    "@angular/animations": "~13.3.11",
    "@angular/cdk": "~13.3.9",
    "@angular/common": "~13.3.11",
    "@angular/compiler": "~13.3.11",
    "@angular/core": "~13.3.11",
    "@angular/forms": "~13.3.11",
    "@angular/platform-browser": "~13.3.11",
    "@angular/platform-browser-dynamic": "~13.3.11",
    "@angular/router": "~13.3.11",
    ...
  },
  "devDependencies": {
    ...
  }
}

I have tried to install the dependency adding the --legacy-peers-dep flag, as stated in this github issue comment (Although it seems to be a solution for angularx-social-login:4 and NOT for @abacritt/angularx-social-login:1, which is newer). That is, using npm i @abacritt/angularx-social-login --legacy-peer-deps, but it is still not working.

I also tried to use version 1.1 instead of 1.2. Because 1.1 was made before adding support for Angular 14. This version (1.1) do work. The installation is different though. And the problem is it seems to be communicating with Google in a way that will be deprecated in March 31, 2023, so is not a very solid solution

Copyright Notice:Content Author:「David Alberici」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/74638394/angular-directive-required-to-implement-googlesigninbuttondirective-in-abacritt

More about “Angular directive required to implement GoogleSigninButtonDirective in @abacritt/[email protected] does not work for Angular 13” related questions

Angular directive required to implement GoogleSigninButtonDirective in @abacritt/[email protected] does not work for Angular 13

Although the library states that @abacritt/angularx-social-login:1 is compatible with Angular 13 and 14, it is not working for my Angular 13 project, this error is thrown after npm start, which see...

Show Detail

Example: Angular 13 Directive to Replace HTML Elements with Angular Components

I thought I would post this example to show how I migrated some older code to Angular 13 that replaced HTML elements with Angular Components. My code originally used ComponentFactoryResolver which ...

Show Detail

Angular 2 Conditional Required Directive

I've created a Conditional Required Directive for Angular 2 from Thierry Templier's post Angular 2 conditional Validators.required?. It works fine but I would like to change the styles on the cont...

Show Detail

Angular 6, directive ngOnChanges does not work with a lambda expression?

I am building an attribute directive, which changes the background color of the host element accounting to a "quality" @input. I found that if I implement ngOnChanges as a lambda expression, the

Show Detail

Angular is not able to find required controller in directive

I am trying to create series of directives which cummunicates via controller. This is what I have now: angular.module('drmApp') .directive('formInput', function () { return { templateU...

Show Detail

Custom Angular Directive not working with dynamic images

I'm working on a custom directive for AngularJs that has a image rotator based on a Jquery Plugin I wrote, which can be seen here Here is my directive .directive('imageRotator', function () {

Show Detail

Angular 2 Directive For Required Fields Not Working

Am creating Angular 2 Directive for required fields which is not Working as Expected Functions I need to achieve is, if that directive is included in template input as an attribute it must check the

Show Detail

Required angular directive not found

I am trying to understand the execution of link function in angular directives. However, I am stuck in a very simple setup. Following is the html code: &lt;!doctype html&gt; &lt;html ng-app="demoA...

Show Detail

Using input[date] directive with Angular 1.2 and 1.3

I need to have an input of type 'date' in my page and I am thinking of using angularJs 'input[date]' directive. But Angular 1.2 does not have it and my application should work with both Angular 1....

Show Detail

Implement Monaco editor in Angular 13

What is the best option to implement Monaco editor in Angular 13? I have seen ngx-monaco-editor, but last update is from 9 months and it’s bumped to Angular 12, also Monaco version there is 0.20.0 ...

Show Detail