bug(cdk): Update Failed : Cannot read property ‘length’ of null

Reproduction

I can’t share my code because it’s a big project, hope the stack will help you
ng update @angular/material --force

Expected Behavior

Working

Actual Behavior

 ** Executing migrations for package '@angular/cdk' **
Cannot read property 'length' of null

Stack trace in log file :

[error] TypeError: Cannot read property 'length' of null
    at Object.computeLineStartsMap (path\node_modules\@angular\cdk\schematics\update-tool\utils\line-mappings.js:39:23)
    at ComponentResourceCollector.resolveExternalStylesheet (path\node_modules\@angular\cdk\schematics\update-tool\component-resource-collector.js:131:47)
    at path\node_modules\@angular\cdk\schematics\update-tool\index.js:97:50
    at Array.forEach (<anonymous>)
    at UpdateProject.migrate (path\node_modules\@angular\cdk\schematics\update-tool\index.js:95:35)
    at runMigrations (path\node_modules\@angular\cdk\schematics\ng-update\devkit-migration-rule.js:128:42)
    at Object.<anonymous> (path\node_modules\@angular\cdk\schematics\ng-update\devkit-migration-rule.js:83:17)
    at Generator.next (<anonymous>)
    at path\node_modules\@angular\cdk\schematics\ng-update\devkit-migration-rule.js:15:71
    at new Promise (<anonymous>)
    at __awaiter (path\node_modules\@angular\cdk\schematics\ng-update\devkit-migration-rule.js:11:12)
    at path\node_modules\@angular\cdk\schematics\ng-update\devkit-migration-rule.js:57:31
    at MergeMapSubscriber.project (path\node_modules\@angular-devkit\schematics\src\rules\call.js:75:24)
    at MergeMapSubscriber._tryNext (path\node_modules\rxjs\internal\operators\mergeMap.js:69:27)
    at MergeMapSubscriber._next (path\node_modules\rxjs\internal\operators\mergeMap.js:59:18)
    at MergeMapSubscriber.Subscriber.next (path\node_modules\rxjs\internal\Subscriber.js:66:18)

Environment

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 10.0.0
Node: 12.4.0
OS: win32 x64

Angular: 10.0.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, language-service, material, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.1000.0
@angular-devkit/build-angular     0.1000.0
@angular-devkit/build-optimizer   0.1000.0
@angular-devkit/build-webpack     0.1000.0
@angular-devkit/core              10.0.0
@angular-devkit/schematics        10.0.0
@angular/flex-layout              10.0.0-beta.32
@ngtools/webpack                  10.0.0
@schematics/angular               9.1.9
@schematics/update                0.1000.0
rxjs                              6.5.5
typescript                        3.9.5
webpack                           4.43.0
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows 10

1 possible answer(s) on “bug(cdk): Update Failed : Cannot read property ‘length’ of null

  1. Reopening this as the error has been fixed, but it doesn’t fix that actual stylesheets are not migrated. It looks like ng update has been run from within a different folder somehow. My understanding though was that the Angular CLI no longer supports this / that the devkit virtual tree always starts from the workspace root.