【问题标题】:Module build failed (from ./node_modules/postcss-loader/src/index.js)模块构建失败(来自 ./node_modules/postcss-loader/src/index.js)
【发布时间】:2021-02-17 18:46:25
【问题描述】:

我正在使用角度和节点,当我运行命令 npm start 时出现此错误

./src/styles.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/styles.scss) 模块构建失败(来自 ./node_modules/postcss-loader/src/index.js): 错误:ENOENT:没有这样的文件或目录,打开 '...\node_modules@angular\material\prebuilt-themes\indigo-pink.css' 在 Object.openSync (fs.js:457:3) 在 Object.readFileSync (fs.js:359:35) 在 Storage.provideSync (...\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:109:13) 在 CachedInputFileSystem.readFileSync (...\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:289:32) 在 Observable._subscribe (...\node_modules@ngtools\webpack\src\webpack-input-host.js:35:51)

我尝试查看一些类似的帖子,但没有解决方案。我的 node.js 版本是

v12.16.1

我的角度版本是

Angular CLI:9.1.9 节点:12.16.1 操作系统:win32 x64

【问题讨论】:

    标签: node.js angular


    【解决方案1】:

    我建议使用节点 10,因为它更适合角度 9。您可以使用 nvm 轻松做到这一点。

    那你可以试试下面的步骤,

    • rm -rf 节点模块
    • npm i --save-exact
    • ng s

    【讨论】:

      【解决方案2】:

      如果您使用的是 angular 并且如果以下操作不起作用。

      @import "../node_modules/ag-grid-community/dist/styles/ag-grid.css";
      @import "../node_modules/ag-grid-community/dist/styles/ag-theme-alpine.css";
      

      然后在 angular.json 文件中尝试以下样式数组

      “样式”:["src/styles.scss", "node_modules/ag-grid-community/dist/styles/ag-grid.css", "node_modules/ag-grid-community/dist/styles/ag-theme-alpine.css", ]

      这是一个有效的例子。

      【讨论】:

        猜你喜欢
        • 2020-11-26
        • 2021-07-15
        • 2020-07-12
        • 1970-01-01
        • 2021-04-17
        • 2019-10-30
        • 2021-11-26
        • 1970-01-01
        相关资源
        最近更新 更多