【问题标题】:Angular project build with Cannot Get / error无法获取 / 错误的 Angular 项目构建
【发布时间】:2021-06-14 12:25:54
【问题描述】:

我尝试在 IntelliJ 中运行我的 Angular 并收到此错误。当我在 localhost 上打开浏览器时,它显示 Cannot GET /

我采取的步骤是:

  • 打开项目
  • npm install -g @angular/cli@latest
  • gradlew 清理构建
  • ng 服务
ERROR in ./src/novus-rego-theme/theme.scss (./node_modules/css-loader/dist/cjs.js??ref--13-1!./node_modules/postcss-loader/src??embedded!./node_modules/
sass-loader/dist/cjs.js??ref--13-3!./src/novus-rego-theme/theme.scss)
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Can't find stylesheet to import.
  ╷
1 │ @import 'node_modules/@angular/material/theming';
  │         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
  C:\Users\paul.d\1 - PROJECTS\simple-reg\reg-ui\src\novus-rego-theme\theme.scss 1:9  root stylesheet
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **

有人遇到过同样的问题吗?

这是我的theme.scss 文件:

@import 'node_modules/@angular/material/theming';
// Plus imports for other components in your app.

// Include the common styles for Angular Material. We include this here so that you only
// have to load a single css file for Angular Material in your app.
// Be sure that you only ever include this mixin once!
@include mat-core();

// Define the palettes for your theme using the Material Design palettes available in palette.scss
// (imported above). For each palette, you can optionally specify a default, lighter, and darker
// hue.
$app-primary: mat-palette($mat-light-blue, 400);
$app-accent: mat-palette($mat-light-blue, A200, A100, A400);

// The warn palette is optional (defaults to red).
$app-warn: mat-palette($mat-red);

// Create the theme object (a Sass map containing all of the palettes).
$app-theme: mat-light-theme($app-primary, $app-accent, $app-warn);

// Include theme styles for core and each component used in your app.
// Alternatively, you can import and @include the theme mixins for each component
// that you are using.
@include angular-material-theme($app-theme);

【问题讨论】:

    标签: css node.js angular webpack angular-cli


    【解决方案1】:

    修改@import 'node_modules/@angular/material/theming';如下。

    @import '~@angular/material/theming';
    

    【讨论】:

    • 有效!我现在可以在浏览器上打开我的项目。谢了哥们。你知道我为什么会收到这个 oauth 错误吗?
    • [HPM] POST /oauth/token -> localhost:8090 [HPM] 尝试将请求 /oauth/token 从 localhost:4200 代理到 localhost:8090 (ECONNREFUSED) (nodejs.org/api/erro) 时出错rs.html#errors_common_system_errors)
    • 您现在是否遇到此错误?这是另一个问题。我建议你发布一个新问题。
    • 是的,是同一个项目。刚刚意识到我收到了这个错误。将发布一个新问题。
    猜你喜欢
    • 1970-01-01
    • 2017-11-20
    • 2017-11-11
    • 2015-12-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-05
    • 2018-07-28
    • 2017-11-06
    相关资源
    最近更新 更多