Angular Material and CDK update 7 to 8 Migration Failure
Asked Answered
P

1

7

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.

Peters answered 10/2, 2020 at 19:40 Comment(5)
Sorry that was a typoPeters
I got same error running ng update @angular/material@8 --allow-dirty --force. Re ran command with --verbose=true to try and get better info and it ran without giving me the error again!!Messiah
Adding the --force or --verbose=true option hasn't changed my output. Still the same vague Error with the same results of the migration failing.Peters
I just ran into this, and even though re-running succeeds, it doesn't do the necessary migration tasks (namely moving imports to the sub directories of /material/[module]). You may want to check that after running the update.Picot
I have experienced the same @Picot packages install and updated fine but the migration for cdk/material fail, with the biggest impact being the import refinementPeters
C
7

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

Carlacarlee answered 25/2, 2020 at 12:28 Comment(2)
That has to be it the project that is failing has that same line "chalk_1.default.green" but a project I have that didn't have this problem has "chalk_1.green"Peters
Changing "chalk_1.default.green" to "chalk_1.green" has the mirgration running fine.Peters

© 2022 - 2024 — McMap. All rights reserved.