Version conflict with ng4-loading-spinner

Viewed 83

My project is using ng4-loading-spinner and Angular 7.2.2. I can see that the last supported version of Angular for ng4-loading-spinner was 6.0.0. Can anyone guide me on how I can resolve this conflict or should I remove the ng4-loading-spinner and use something else for spinning?

187 http fetch GET 200 https://registry.npmjs.org/@angular%2fcore 56ms (cache revalidated)
188 silly fetch manifest rxjs@^6.1.0
189 http fetch GET 200 https://registry.npmjs.org/rxjs 44ms (cache revalidated)
190 silly fetch manifest zone.js@^0.8.4
191 http fetch GET 200 https://registry.npmjs.org/zone.js 37ms (cache revalidated)
192 timing idealTree Completed in 2311ms
193 timing command:install Completed in 2326ms
194 verbose stack Error: could not resolve
194 verbose stack     at PlaceDep.failPeerConflict (C:\Users\stas\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\place-dep.js:549:25)
194 verbose stack     at PlaceDep.place (C:\Users\stas\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\place-dep.js:199:21)
194 verbose stack     at new PlaceDep (C:\Users\stas\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\place-dep.js:73:10)
194 verbose stack     at C:\Users\stas\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:990:31
194 verbose stack     at Array.map (<anonymous>)
194 verbose stack     at Arborist.[buildDepStep] (C:\Users\stas\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:990:8)
194 verbose stack     at async Arborist.buildIdealTree (C:\Users\stas\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:218:7)
194 verbose stack     at async Promise.all (index 1)
194 verbose stack     at async Arborist.reify (C:\Users\stas\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:154:5)
194 verbose stack     at async Install.exec (C:\Users\stas\AppData\Roaming\npm\node_modules\npm\lib\commands\install.js:145:5)
195 verbose cwd D:\work\EDMS4.0
196 verbose Windows_NT 10.0.19044
197 verbose node v16.17.0
198 verbose npm  v8.18.0
199 error code ERESOLVE
200 error ERESOLVE could not resolve
201 error
202 error While resolving: [1mng4-loading-spinner[22m@[1m1.2.3[22m
202 error Found: [1m@angular/core[22m@[1m7.2.2[22m[2m[22m
202 error [2mnode_modules/@angular/core[22m
202 error   [35mpeer[39m [1m@angular/core[22m@"[1m7.2.2[22m" from [1m@angular/animations[22m@[1m7.2.2[22m[2m[22m
202 error   [2mnode_modules/@angular/animations[22m
202 error     [35mpeer[39m [1m@angular/animations[22m@"[1m^7.0.0[22m" from [1mangular2-notifications[22m@[1m2.0.0[22m[2m[22m
202 error     [2mnode_modules/angular2-notifications[22m
202 error       [1mangular2-notifications[22m@"[1m^2.0.0[22m" from the root project
202 error     [1m@angular/animations[22m@"[1m~7.2.0[22m" from the root project
202 error   [35mpeer[39m [1m@angular/core[22m@"[1m7.2.2[22m" from [1m@angular/common[22m@[1m7.2.2[22m[2m[22m
202 error   [2mnode_modules/@angular/common[22m
202 error     [35mpeer[39m [1m@angular/common[22m@"[1m7.2.2[22m" from [1m@angular/forms[22m@[1m7.2.2[22m[2m[22m
202 error     [2mnode_modules/@angular/forms[22m
202 error       [1m@angular/forms[22m@"[1m~7.2.0[22m" from the root project
202 error     [35mpeer[39m [1m@angular/common[22m@"[1m7.2.2[22m" from [1m@angular/platform-browser[22m@[1m7.2.2[22m[2m[22m
202 error     [2mnode_modules/@angular/platform-browser[22m
202 error       [35mpeer[39m [1m@angular/platform-browser[22m@"[1m7.2.2[22m" from [1m@angular/forms[22m@[1m7.2.2[22m[2m[22m
202 error       [2mnode_modules/@angular/forms[22m
202 error         [1m@angular/forms[22m@"[1m~7.2.0[22m" from the root project
202 error       4 more (@angular/platform-browser-dynamic, @angular/router, ...)
202 error     9 more (@angular/platform-browser-dynamic, @angular/router, ...)
202 error   12 more (@angular/forms, @angular/platform-browser, ...)
202 error
202 error Could not resolve dependency:
202 error [35mpeer[39m [1m@angular/core[22m@"[1m^6.0.0[22m" from [1mng4-loading-spinner[22m@[1m1.2.3[22m[2m[22m
202 error [2mnode_modules/ng4-loading-spinner[22m
202 error   [1mng4-loading-spinner[22m@"[1m^1.2.3[22m" from the root project
202 error
202 error Conflicting peer dependency: [1m@angular/core[22m@[1m6.1.10[22m[2m[22m
202 error [2mnode_modules/@angular/core[22m
202 error   [35mpeer[39m [1m@angular/core[22m@"[1m^6.0.0[22m" from [1mng4-loading-spinner[22m@[1m1.2.3[22m[2m[22m
202 error   [2mnode_modules/ng4-loading-spinner[22m
202 error     [1mng4-loading-spinner[22m@"[1m^1.2.3[22m" from the root project
202 error
202 error Fix the upstream dependency conflict, or retry
202 error this command with --force, or --legacy-peer-deps
202 error to accept an incorrect (and potentially broken) dependency resolution.
202 error
202 error See C:\Users\stas\AppData\Local\npm-cache\eresolve-report.txt for a full report.
203 verbose exit 1
204 timing npm Completed in 2527ms

Furthermore, the log report states:

While resolving: ng4-loading-spinner@1.2.3
Found: @angular/core@7.2.2
node_modules/@angular/core
  peer @angular/core@"7.2.2" from @angular/animations@7.2.2
  node_modules/@angular/animations
    peer @angular/animations@"^7.0.0" from angular2-notifications@2.0.0
    node_modules/angular2-notifications
      angular2-notifications@"^2.0.0" from the root project
    @angular/animations@"~7.2.0" from the root project
  peer @angular/core@"7.2.2" from @angular/common@7.2.2
  node_modules/@angular/common
    peer @angular/common@"7.2.2" from @angular/forms@7.2.2
    node_modules/@angular/forms
      @angular/forms@"~7.2.0" from the root project
    peer @angular/common@"7.2.2" from @angular/platform-browser@7.2.2
    node_modules/@angular/platform-browser
      peer @angular/platform-browser@"7.2.2" from @angular/forms@7.2.2
      node_modules/@angular/forms
        @angular/forms@"~7.2.0" from the root project
      peer @angular/platform-browser@"7.2.2" from @angular/platform-browser-dynamic@7.2.2
      node_modules/@angular/platform-browser-dynamic
        peer @angular/platform-browser-dynamic@"<8.0.0" from @swimlane/ngx-datatable@14.0.0
        node_modules/@swimlane/ngx-datatable
          @swimlane/ngx-datatable@"^14.0.0" from the root project
        @angular/platform-browser-dynamic@"~7.2.0" from the root project
      peer @angular/platform-browser@"7.2.2" from @angular/router@7.2.2
      node_modules/@angular/router
        @angular/router@"~7.2.0" from the root project
      peer @angular/platform-browser@"<8.0.0" from @swimlane/ngx-datatable@14.0.0
      node_modules/@swimlane/ngx-datatable
        @swimlane/ngx-datatable@"^14.0.0" from the root project
      @angular/platform-browser@"~7.2.0" from the root project
    peer @angular/common@"7.2.2" from @angular/platform-browser-dynamic@7.2.2
    node_modules/@angular/platform-browser-dynamic
      peer @angular/platform-browser-dynamic@"<8.0.0" from @swimlane/ngx-datatable@14.0.0
      node_modules/@swimlane/ngx-datatable
        @swimlane/ngx-datatable@"^14.0.0" from the root project
      @angular/platform-browser-dynamic@"~7.2.0" from the root project
    peer @angular/common@"7.2.2" from @angular/router@7.2.2
    node_modules/@angular/router
      @angular/router@"~7.2.0" from the root project
    peer @angular/common@">=7.0.0" from @ngx-translate/http-loader@4.0.0
    node_modules/@ngx-translate/http-loader
      @ngx-translate/http-loader@"^4.0.0" from the root project
    peer @angular/common@"<8.0.0" from @swimlane/ngx-datatable@14.0.0
    node_modules/@swimlane/ngx-datatable
      @swimlane/ngx-datatable@"^14.0.0" from the root project
    peer @angular/common@"^7.0.0-rc.0 || ^7.0.0" from angular-highcharts@7.1.0
    node_modules/angular-highcharts
      angular-highcharts@"^7.1.0" from the root project
    peer @angular/common@"^7.0.0" from angular2-notifications@2.0.0
    node_modules/angular2-notifications
      angular2-notifications@"^2.0.0" from the root project
    peer @angular/common@"^2.0.0-rc.0 || >=2.0.0" from highcharts-angular@2.4.0
    node_modules/highcharts-angular
      highcharts-angular@"^2.4.0" from the root project
    peer @angular/common@">=6.0.0" from ngx-bootstrap@3.2.0
    node_modules/ngx-bootstrap
      ngx-bootstrap@"^3.2.0" from the root project
    @angular/common@"~7.2.0" from the root project
  peer @angular/core@"7.2.2" from @angular/forms@7.2.2
  node_modules/@angular/forms
    @angular/forms@"~7.2.0" from the root project
  peer @angular/core@"7.2.2" from @angular/platform-browser@7.2.2
  node_modules/@angular/platform-browser
    peer @angular/platform-browser@"7.2.2" from @angular/forms@7.2.2
    node_modules/@angular/forms
      @angular/forms@"~7.2.0" from the root project
    peer @angular/platform-browser@"7.2.2" from @angular/platform-browser-dynamic@7.2.2
    node_modules/@angular/platform-browser-dynamic
      peer @angular/platform-browser-dynamic@"<8.0.0" from @swimlane/ngx-datatable@14.0.0
      node_modules/@swimlane/ngx-datatable
        @swimlane/ngx-datatable@"^14.0.0" from the root project
      @angular/platform-browser-dynamic@"~7.2.0" from the root project
    peer @angular/platform-browser@"7.2.2" from @angular/router@7.2.2
    node_modules/@angular/router
      @angular/router@"~7.2.0" from the root project
    peer @angular/platform-browser@"<8.0.0" from @swimlane/ngx-datatable@14.0.0
    node_modules/@swimlane/ngx-datatable
      @swimlane/ngx-datatable@"^14.0.0" from the root project
    @angular/platform-browser@"~7.2.0" from the root project
  peer @angular/core@"7.2.2" from @angular/platform-browser-dynamic@7.2.2
  node_modules/@angular/platform-browser-dynamic
    peer @angular/platform-browser-dynamic@"<8.0.0" from @swimlane/ngx-datatable@14.0.0
    node_modules/@swimlane/ngx-datatable
      @swimlane/ngx-datatable@"^14.0.0" from the root project
    @angular/platform-browser-dynamic@"~7.2.0" from the root project
  peer @angular/core@"7.2.2" from @angular/router@7.2.2
  node_modules/@angular/router
    @angular/router@"~7.2.0" from the root project
  peer @angular/core@">=7.0.0" from @ngx-translate/core@11.0.1
  node_modules/@ngx-translate/core
    peer @ngx-translate/core@">=11.0.0" from @ngx-translate/http-loader@4.0.0
    node_modules/@ngx-translate/http-loader
      @ngx-translate/http-loader@"^4.0.0" from the root project
    @ngx-translate/core@"^11.0.1" from the root project
  peer @angular/core@"<8.0.0" from @swimlane/ngx-datatable@14.0.0
  node_modules/@swimlane/ngx-datatable
    @swimlane/ngx-datatable@"^14.0.0" from the root project
  peer @angular/core@"^7.0.0-rc.0 || ^7.0.0" from angular-highcharts@7.1.0
  node_modules/angular-highcharts
    angular-highcharts@"^7.1.0" from the root project
  peer @angular/core@"^7.0.0" from angular2-notifications@2.0.0
  node_modules/angular2-notifications
    angular2-notifications@"^2.0.0" from the root project
  peer @angular/core@">=2.3.1 <8.0.0 || >7.0.0-beta <8.0.0" from codelyzer@4.5.0
  node_modules/codelyzer
    dev codelyzer@"~4.5.0" from the root project
  peer @angular/core@"^2.0.0-rc.0 || >=2.0.0" from highcharts-angular@2.4.0
  node_modules/highcharts-angular
    highcharts-angular@"^2.4.0" from the root project
  peer @angular/core@">=6.0.0" from ngx-bootstrap@3.2.0
  node_modules/ngx-bootstrap
    ngx-bootstrap@"^3.2.0" from the root project
  @angular/core@"~7.2.0" from the root project

Could not resolve dependency:
peer @angular/core@"^6.0.0" from ng4-loading-spinner@1.2.3
node_modules/ng4-loading-spinner
  ng4-loading-spinner@"^1.2.3" from the root project

Conflicting peer dependency: @angular/core@6.1.10
node_modules/@angular/core
  peer @angular/core@"^6.0.0" from ng4-loading-spinner@1.2.3
  node_modules/ng4-loading-spinner
    ng4-loading-spinner@"^1.2.3" from the root project

Fix the upstream dependency conflict, or retry
this command with --force, or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.

Raw JSON explanation object:

{
  "code": "ERESOLVE",
  "edge": {
    "type": "peer",
    "name": "@angular/core",
    "spec": "^6.0.0",
    "error": "INVALID",
    "from": {
      "name": "ng4-loading-spinner",
      "version": "1.2.3",
      "location": "node_modules/ng4-loading-spinner",
      "isWorkspace": false,
      "dependents": [
        {
          "type": "prod",
          "name": "ng4-loading-spinner",
          "spec": "^1.2.3",
          "from": {
            "location": "D:\\work\\EDMS4.0"
          }
        }
      ]
    }
  },
  "dep": {
    "name": "@angular/core",
    "version": "6.1.10",
    "whileInstalling": {
      "name": "ng4-loading-spinner",
      "version": "1.2.3",
      "path": "D:\\work\\EDMS4.0\\node_modules\\ng4-loading-spinner"
    },
    "location": "node_modules/@angular/core",
    "isWorkspace": false,
    "dependents": [
      {
        "type": "peer",
        "name": "@angular/core",
        "spec": "^6.0.0",
        "error": "INVALID",
        "from": {
          "name": "ng4-loading-spinner",
          "version": "1.2.3",
          "location": "node_modules/ng4-loading-spinner",
          "isWorkspace": false,
          "dependents": [
            {
              "type": "prod",
              "name": "ng4-loading-spinner",
              "spec": "^1.2.3",
              "from": {
                "location": "D:\\work\\EDMS4.0"
              }
            }
          ]
        }
      }
    ]
  },
  "current": {
    "name": "@angular/core",
    "version": "7.2.2",
    "location": "node_modules/@angular/core",
    "isWorkspace": false,
    "dependents": [
      {
        "type": "peer",
        "name": "@angular/core",
        "spec": "7.2.2",
        "from": {
          "name": "@angular/animations",
          "version": "7.2.2",
          "location": "node_modules/@angular/animations",
          "isWorkspace": false,
          "dependents": [
            {
              "type": "peer",
              "name": "@angular/animations",
              "spec": "^7.0.0",
              "from": {
                "name": "angular2-notifications",
                "version": "2.0.0",
                "location": "node_modules/angular2-notifications",
                "isWorkspace": false,
                "dependents": [
                  {
                    "type": "prod",
                    "name": "angular2-notifications",
                    "spec": "^2.0.0",
                    "from": {
                      "location": "D:\\work\\EDMS4.0"
                    }
                  }
                ]
              }
            },
            {
              "type": "prod",
              "name": "@angular/animations",
              "spec": "~7.2.0",
              "from": {
                "location": "D:\\work\\EDMS4.0"
              }
            }
          ]
        }
      },
2 Answers

Since you're running npm 8+ you can use the overrides property of the package.json:

{
  ...
  "overrides": {
    // the troublesome package
    "ng4-loading-spinner": {
      // list the unmatched dependencies here
      "@angular/core": "$@angular/core"
      // this syntax means: if that package depends on @angular/core,
      // use the version I have installed instead of the one it needs
    }
  }
}

Manually update ng4-loading-spinner package.json file.

node_modules/ng4-loading-spinner/package.json

{
    ...
    "peerDependencies": {
      "@angular/core": "^6.0.0 || ^7.0.0""
    },
    ...
}

then save, and try again.

Original answer here.

Related