It's always helpful when the error message is straightforward - "Cannot find module" simply means the module is not present :)
To verify this, I checked the node_modules
directory and then navigated to @angular/material/core/
to confirm the absence of a common-behaviors
folder. However, within the core module's index.t.ts
file, I discovered the following declarations:
export declare type _Constructor<T> = new (...args: any[]) => T;
export declare type _AbstractConstructor<T = object> = abstract new (...args: any[]) => T;
This suggests that the code was rearranged during refactoring, causing some changes in location. To resolve my issue, all I had to do was adjust the imports to the correct path, switching from:
import { AbstractConstructor, Constructor } from '@angular/material/core/common-behaviors/constructor';
to:
import { _AbstractConstructor, _Constructor } from '@angular/material/core';
Naturally, a slight modification to the code was necessary since these classes now have an underscore preceding their names.
An easy fix, though not immediately apparent, especially since it was not outlined in the Angular Migration guide or handled by the upgrade script itself.