Tung Vo
Tung Vo

Reputation: 2549

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

Upvotes: 5

Views: 43694

Answers (3)

Steve Madue
Steve Madue

Reputation: 11

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

Upvotes: 1

Milan Kumar
Milan Kumar

Reputation: 171

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.

Upvotes: 4

Shashan Sooriyahetti
Shashan Sooriyahetti

Reputation: 878

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

Upvotes: 3

Related Questions