SAP / spartacus

Spartacus is a lean, Angular-based JavaScript storefront for SAP Commerce Cloud that communicates exclusively through the Commerce REST API.
Apache License 2.0
744 stars 389 forks source link

Update schematics problem #8655

Closed znikola closed 4 years ago

znikola commented 4 years ago

A client reported a bug when upgrading from 1.5.x to 2.0.x:

[error] TypeError: schematics_1.getSourceNodes is not a function
at <...>/node_modules/@spartacus/schematics/src/migrations/2_0/component-deprecations/component-deprecations.js:17:40
    at MergeMapSubscriber.project (/private/var/folders/5v/wx2rbzm555g08n9mwmjfp5_00000gn/T/angular-cli-packages-0OpcVk/node_modules/@angular-devkit/schematics/src/rules/call.js:75:24)
    at MergeMapSubscriber._tryNext (/private/var/folders/5v/wx2rbzm555g08n9mwmjfp5_00000gn/T/angular-cli-packages-0OpcVk/node_modules/rxjs/internal/operators/mergeMap.js:69:27)
    at MergeMapSubscriber._next (/private/var/folders/5v/wx2rbzm555g08n9mwmjfp5_00000gn/T/angular-cli-packages-0OpcVk/node_modules/rxjs/internal/operators/mergeMap.js:59:18)
    at MergeMapSubscriber.Subscriber.next (/private/var/folders/5v/wx2rbzm555g08n9mwmjfp5_00000gn/T/angular-cli-packages-0OpcVk/node_modules/rxjs/internal/Subscriber.js:66:18)
    at Observable._subscribe (/private/var/folders/5v/wx2rbzm555g08n9mwmjfp5_00000gn/T/angular-cli-packages-0OpcVk/node_modules/rxjs/internal/util/subscribeToArray.js:5:20)
    at Observable._trySubscribe (/private/var/folders/5v/wx2rbzm555g08n9mwmjfp5_00000gn/T/angular-cli-packages-0OpcVk/node_modules/rxjs/internal/Observable.js:44:25)
    at Observable.subscribe (/private/var/folders/5v/wx2rbzm555g08n9mwmjfp5_00000gn/T/angular-cli-packages-0OpcVk/node_modules/rxjs/internal/Observable.js:30:22)
    at MergeMapOperator.call (/private/var/folders/5v/wx2rbzm555g08n9mwmjfp5_00000gn/T/angular-cli-packages-0OpcVk/node_modules/rxjs/internal/operators/mergeMap.js:39:23)
    at Observable.subscribe (/private/var/folders/5v/wx2rbzm555g08n9mwmjfp5_00000gn/T/angular-cli-packages-0OpcVk/node_modules/rxjs/internal/Observable.js:25:31)
    at MapOperator.call (/private/var/folders/5v/wx2rbzm555g08n9mwmjfp5_00000gn/T/angular-cli-packages-0OpcVk/node_modules/rxjs/internal/operators/map.js:32:23)
    at Observable.subscribe (/private/var/folders/5v/wx2rbzm555g08n9mwmjfp5_00000gn/T/angular-cli-packages-0OpcVk/node_modules/rxjs/internal/Observable.js:25:31)
    at Object.subscribeToResult (/private/var/folders/5v/wx2rbzm555g08n9mwmjfp5_00000gn/T/angular-cli-packages-0OpcVk/node_modules/rxjs/internal/util/subscribeToResult.js:12:23)
    at MergeMapSubscriber._innerSub (/private/var/folders/5v/wx2rbzm555g08n9mwmjfp5_00000gn/T/angular-cli-packages-0OpcVk/node_modules/rxjs/internal/operators/mergeMap.js:82:53)
    at MergeMapSubscriber._tryNext (/private/var/folders/5v/wx2rbzm555g08n9mwmjfp5_00000gn/T/angular-cli-packages-0OpcVk/node_modules/rxjs/internal/operators/mergeMap.js:76:14)
    at MergeMapSubscriber._next (/private/var/folders/5v/wx2rbzm555g08n9mwmjfp5_00000gn/T/angular-cli-packages-0OpcVk/node_modules/rxjs/internal/operators/mergeMap.js:59:18)
znikola commented 4 years ago

Their package.json (note that non-relevant dependencies were removed):

{
  "name": "mystore-beta-test",
  "version": "0.0.0",
  "scripts": {
    ...  
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^9.1.12",
    "@angular/cdk": "^9.2.4",
    "@angular/common": "~9.1.12",
    "@angular/compiler": "~9.1.12",
    "@angular/core": "^9.1.12",
    "@angular/forms": "~9.1.12",
    "@angular/material": "^9.2.4",
    "@angular/platform-browser": "~9.1.12",
    "@angular/platform-browser-dynamic": "~9.1.12",
    "@angular/platform-server": "^9.1.12",
    "@angular/pwa": "^0.801.0",
    "@angular/router": "~9.1.12",
    "@angular/service-worker": "~9.1.12",
    "@spartacus/assets": "~1.5.6",
    "@spartacus/core": "~1.5.6",
    "@spartacus/storefront": "~1.5.6",
    "@spartacus/styles": "~1.5.6",
    ...
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.901.12",
    "@angular/cli": "^9.1.12",
    "@angular/compiler-cli": "^9.1.12",
    "@angular/language-service": "~9.1.12",
    "@spartacus/schematics": "~1.5.6",
    ...
  }
}
znikola commented 4 years ago

One possible cause is that the angular dependencies were not properly aligned. Note that in the package.json (provided above ) some dependencies use ~, while others use ^. Another possible cause is the "@angular/pwa": "^0.801.0",, which was aligned with the rest (v8 vs. v9).

Having non-aligned dependencies like this seems to be confusing for Angular.

The solution was to align them like this:

{
  "name": "mystore-beta-test",
  "version": "0.0.0",
  "scripts": {
    ...
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^9.1.12",
    "@angular/cdk": "^9.2.4",
    "@angular/common": "^9.1.12",
    "@angular/compiler": "^9.1.12",
    "@angular/core": "^9.1.12",
    "@angular/forms": "^9.1.12",
    "@angular/material": "^9.2.4",
    "@angular/platform-browser": "^9.1.12",
    "@angular/platform-browser-dynamic": "^9.1.12",
    "@angular/platform-server": "^9.1.12",
    "@angular/pwa": "^0.901.12",
    "@angular/router": "^9.1.12",
    "@angular/service-worker": "^9.1.12",
    "@spartacus/assets": "~1.5.6",
    "@spartacus/core": "~1.5.6",
    "@spartacus/storefront": "~1.5.6",
    "@spartacus/styles": "~1.5.6",
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.901.12",
    "@angular-devkit/schematics": "^9.1.12",
    "@angular/cli": "^9.1.12",
    "@angular/compiler-cli": "^9.1.12",
    "@angular/language-service": "^9.1.12",
    "@spartacus/schematics": "~1.5.6",
    ...
  }
}