简体   繁体   中英

Module build failed (from ./node_modules/postcss-loader/src/index.js)

I am working with angular and node, when i run the command npm start i get this error

ERROR in./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) Module build failed (from:/node_modules/postcss-loader/src/index:js), Error. ENOENT. no such file or directory. open '...\node_modules@angular\material\prebuilt-themes\indigo-pink:css' at Object:openSync (fs.js.457:3) at Object:readFileSync (fs.js.359.35) at Storage.provideSync (.::\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js.109.13) at CachedInputFileSystem.readFileSync (.::\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js.289.32) at Observable._subscribe (.::\node_modules@ngtools\webpack\src\webpack-input-host.js:35:51)

I have tried view some similar post but no solution work. My node.js version is

v12.16.1

My angular version is

Angular CLI: 9.1.9 Node: 12.16.1 OS: win32 x64

I recommend to use node 10 as it more suitable for angular 9. You can easily do that using nvm .

Then you can try below steps,

  • rm -rf node_modules
  • npm i --save-exact
  • ng s

The issue is that the postcss with the CSS module is not configured or installed. I resolved the issue by installing this package:

npm install babel-plugin-react-css-modules --save

You can readmore about resolving the issue here: https://dev.to/daveirvine/postcss-with-css-modules-andreact-51ln

If you are using angular and if following is not working.

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

then try the following inside styles array in angular.json file

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

It is a working example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM