angular 9 videogular2 could not be resolved to NgModule

2.5k Views Asked by At

I'm developing an angular 9 app and face problems while integrating videogular2 when I install it by official tutorial everything is ok till I try to serve the project then I get these errors

ERROR in node_modules/videogular2/src/core/core.d.ts:29:22 - error NG6002: Appears in the NgModule.imports of VideoPlayerModule, but could not be resolved to an NgModule class

29 export declare class VgCoreModule { ~~~~~~~~~~~~ node_modules/videogular2/src/controls/controls.d.ts:1:22 - error NG6002: Appears in the NgModule.imports of VideoPlayerModule, but could not be resolved to an NgModule class

1 export declare class VgControlsModule { ~~~~~~~~~~~~~~~~ node_modules/videogular2/src/overlay-play/overlay-play.d.ts:1:22 - error NG6002: Appears in the NgModule.imports of VideoPlayerModule, but could not be resolved to an NgModule class

1 export declare class VgOverlayPlayModule { ~~~~~~~~~~~~~~~~~~~ node_modules/videogular2/src/buffering/buffering.d.ts:1:22 - error NG6002: Appears in the NgModule.imports of VideoPlayerModule, but could not be resolved to an NgModule class

1 export declare class VgBufferingModule { ~~~~~~~~~~~~~~~~~ node_modules/videogular2/src/streaming/streaming.d.ts:6:22 - error NG6002: Appears in the NgModule.imports of VideoPlayerModule, but could not be resolved to an NgModule class

6 export declare class VgStreamingModule { ~~~~~~~~~~~~~~~~~ src/app/apps/video-player/video-player.module.ts:42:14 - error NG6002: Appears in the NgModule.imports of AppsModule, but itself has errors

42 export class VideoPlayerModule ~~~~~~~~~~~~~~~~~ src/app/apps/apps.module.ts:29:14 - error NG6002: Appears in the NgModule.imports of AppModule, but itself has errors

29 export class AppsModule ~~~~~~~~~~

** Angular Live Development Server is listening on localhost:7777, open your browser on http://localhost:7777/ **

Here is my package.json file

{
"name": "test",
"version": "9.0.0",
"scripts": {
    "ng": "ng",
    "start": "ng serve --open",
    "start-hmr": "ng serve --configuration hmr --source-map=false --hmr-warning=false",
    "start-hmr-sourcemaps": "ng serve --configuration hmr --source-map=true --hmr-warning=false",
    "build": "node --max_old_space_size=6144 ./node_modules/@angular/cli/bin/ng build --dev",
    "build-stats": "node --max_old_space_size=6144 ./node_modules/@angular/cli/bin/ng build --dev --stats-json",
    "build-prod": "node --max_old_space_size=6144 ./node_modules/@angular/cli/bin/ng build --prod",
    "build-prod-stats": "node --max_old_space_size=6144 ./node_modules/@angular/cli/bin/ng build --prod --stats-json",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "bundle-report": "webpack-bundle-analyzer dist/stats.json"
},
"private": true,
"dependencies": {
    "@agm/core": "1.1.0",
    "@angular/animations": "9.0.0",
    "@angular/cdk": "9.0.0",
    "@angular/common": "9.0.0",
    "@angular/compiler": "9.0.0",
    "@angular/core": "9.0.0",
    "@angular/flex-layout": "9.0.0-beta.29",
    "@angular/forms": "9.0.0",
    "@angular/material": "9.0.0",
    "@angular/material-moment-adapter": "9.0.0",
    "@angular/platform-browser": "9.0.0",
    "@angular/platform-browser-dynamic": "9.0.0",
    "@angular/router": "9.0.0",
    "@auth0/angular-jwt": "4.0.0",
    "@ngrx/effects": "8.6.0",
    "@ngrx/router-store": "8.6.0",
    "@ngrx/store": "8.6.0",
    "@ngrx/store-devtools": "8.6.0",
    "@ngx-translate/core": "12.0.0",
    "@swimlane/dragula": "3.8.0",
    "@swimlane/ngx-charts": "13.0.2",
    "@swimlane/ngx-datatable": "16.0.3",
    "@swimlane/ngx-dnd": "8.1.0",
    "@types/prismjs": "1.16.0",
    "angular-calendar": "0.28.2",
    "angular-in-memory-web-api": "0.9.0",
    "chart.js": "2.9.3",
    "classlist.js": "1.1.20150312",
    "d3": "5.15.0",
    "date-fns": "2.9.0",
    "hammerjs": "2.0.8",
    "lodash": "4.17.15",
    "moment": "2.24.0",
    "ng2-charts": "2.3.0",
    "ngrx-store-freeze": "0.2.4",
    "ngx-bar-rating": "^1.1.0",
    "ngx-color-picker": "8.2.0",
    "ngx-cookie-service": "2.3.0",
    "ngx-spinner": "9.0.1",
    "perfect-scrollbar": "1.4.0",
    "prismjs": "1.19.0",
    "rxjs": "6.5.4",
    "tslib": "1.10.0",
    "videogular2": "^6.1.1",
    "web-animations-js": "2.3.2",
    "zone.js": "0.10.2"
},
"devDependencies": {
    "@angular-devkit/build-angular": "0.900.1",
    "@angular/cli": "9.0.1",
    "@angular/compiler-cli": "9.0.0",
    "@angular/language-service": "9.0.0",
    "@angularclass/hmr": "2.1.3",
    "@types/core-js": "2.5.3",
    "@types/jasmine": "3.5.2",
    "@types/jasminewd2": "2.0.8",
    "@types/lodash": "4.14.149",
    "@types/node": "12.12.6",
    "codelyzer": "5.2.1",
    "jasmine-core": "3.5.0",
    "jasmine-spec-reporter": "4.2.1",
    "karma": "4.3.0",
    "karma-chrome-launcher": "3.1.0",
    "karma-coverage-istanbul-reporter": "2.1.1",
    "karma-jasmine": "2.0.1",
    "karma-jasmine-html-reporter": "1.5.1",
    "protractor": "5.4.3",
    "ts-node": "8.3.0",
    "tslint": "5.18.0",
    "typescript": "3.7.5",
    "webpack-bundle-analyzer": "3.6.0"
}

}

and this is my module

import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';

import { VideoPlayerComponent } from './video-player.component';
import { CommonModule } from '@angular/common';
import { MatCardModule } from '@angular/material/card';

import { VgCoreModule } from 'videogular2/core';
import { VgControlsModule } from 'videogular2/controls';
import { VgOverlayPlayModule } from 'videogular2/overlay-play';
import { VgBufferingModule } from 'videogular2/buffering';
import { VgStreamingModule } from 'videogular2/streaming';

import { AuthGuard } from '../auth/auth.guards/auth.guard';


const routes = [
    {
        path     : 'video',
        component: VideoPlayerComponent,
        canActivate: [AuthGuard]
        // resolve  : {
        //     profile: ProfileService
        // }
    }
];
@NgModule({
    declarations: [VideoPlayerComponent],
    imports: [
        CommonModule,
        MatCardModule,

        VgCoreModule,
        VgControlsModule,
        VgOverlayPlayModule,
        VgBufferingModule,
        VgStreamingModule,
        RouterModule.forChild(routes)

    ]
})
export class VideoPlayerModule
{
}
3

There are 3 best solutions below

2
On

I had the same problem, ensure you've installed

  1. tslint
  2. typescript

either locally or global

npm i -g tslint --f && npm i -g typescript --f

1
On

Videogular2 does not support angular 9 yet.

You can use this ngx-videogular (fork of videogular2) until support is added, as recommended in this github issue.

Another option is to disable Ivy, like indicated in the other answer. However, you'll loose all the benefits of Ivy by doing that.

0
On

The value of the enableIvy flag is set to true by default, as of version 9.

"angularCompilerOptions": { "enableIvy": false }

solve my problem