Search code examples
angularangular-materialangular-cdk

Angular Material and CDK update 7 to 8 Migration Failure


I am attempting to update angular material and the cdk from version 7 to 8. Package update goes fine for both but the migration for both fail every time with a very "helpful" error of

Cannot read property 'green' of undefined Migration failed. See above for furhter details.

I am having a really tough time trying to track where this could be coming from. I have done a generic search accross my project for "green" and got nothing. I have wipe my node_modules and reinstalled but continue to get this.

I even got this when trying to execute just the migration alone with a

ng update @angular/material@8 --migrationOnly=true --from=7 --to=8

Any suggestions/help would be much appreciated.


Solution

  • Same error here. The log points to onMigrationComplete() in .\node_modules\@angular\material\schematics\ng-update\index.js, so I removed the references to chalk_1.default there:

    BEFORE

    function onMigrationComplete(targetVersion, hasFailures) {
        console.log();
        console.log(chalk_1.default.green(`  ✓  Updated Angular Material to ${targetVersion}`));
        console.log();
        if (hasFailures) {
            console.log(chalk_1.default.yellow('  ⚠  Some issues were detected but could not be fixed automatically. Please check the ' +
                'output above and fix these issues manually.'));
        }
    }
    

    AFTER

    function onMigrationComplete(targetVersion, hasFailures) {
        console.log();
        console.log(`  ✓  Updated Angular Material to ${targetVersion}`);
        console.log();
        if (hasFailures) {
            console.log('  ⚠  Some issues were detected but could not be fixed automatically. Please check the ' +
                'output above and fix these issues manually.');
        }
    }
    

    With the AFTER version, migration runs through