找不到或无法读取要导入的文件:@material/button/mdc-button

File to import not found or unreadable: @material/button/mdc-button

我使用 Angular v6.1.2 并且只是在入门公会之后的初始项目。然后我在 link https://www.npmjs.com/package/material-components-web,

之后添加 MDC

然后在我的项目 styles.scss 文件中,我只是像这样导入 MDC scss

@import "~material-components-web/material-components-web";

然后我 运行 应用程序显示了这个错误

Module build failed: @import "@material/button/mdc-button"; ^ File to import not found or unreadable: @material/button/mdc-button. and so on...

我试过像下面的代码一样在 angular.json 中添加路径,但它不起作用。

"stylePreprocessorOptions": {
    "includePaths": [
        "./node_modules/material-components-web", "./node_modules/@material"
    ]
}

还有什么我想念的吗?

"stylePreprocessorOptions": {
    "includePaths": [
        "./node_modules"
    ]
}

只包含在 node_modules 路径上,因为 material-components-web@material 需要知道父路径。