Search code examples
ag-grid-angular

ag-grid-angular.module.d.ts has no exported member 'ɵɵInjectorDeclaration' i0.ɵɵInjectorDeclaration<AgGridModule>;


I have an Angular 11 project that uses AG Grid. Since updating from v27 to v28 of ag-grid-angular I get many errors of the form below.

node_modules/ag-grid-angular/lib/ag-grid-angular.module.d.ts:7:21 - error TS2694: Namespace '"/node_modules/@angular/core/core"' has no exported member 'ɵɵInjectorDeclaration'.
    
    7     static ɵinj: i0.ɵɵInjectorDeclaration<AgGridModule>;

Solution

  • In v28 of AG Grid the Angular packages are now published and distributed in the Ivy package format. This means that from v28 onwards the AG Grid Angular packages have a minimum peer dependency on Angular v12.

    If you cannot upgrade your application to Angular v12 then you will need to use the legacy package from AG Grid instead.

    These are either ag-grid-angular-legacy or @ag-grid-community/angular-legacy respectively for Package / Module setups.

    So in your package.json file, you will need to change the AG Grid package to be the legacy version.

    "dependencies": {
       ...
    -    "ag-grid-angular": "^27.3.0",
    +    "ag-grid-angular-legacy": "^28.0.0",
       ...
    

    You will then need to update all the import paths throughout your application to use the legacy package name too.

    - import { AgGridModule } from 'ag-grid-angular';
    + import { AgGridModule } from 'ag-grid-angular-legacy';
    

    The only difference between the standard and legacy packages is the Angular distribution format, so aside from standard major version breaking changes, the legacy package should act as a drop-in replacement.

    This was taken from this update post