6

I'm executing ng serve and it fails to compile after the chunks are produced.

The same repository is working on a colleague's machine, with same versions as below:

  • Node version: 10.16.3
  • NPM version: 6.9.0
  • @angular/cli: 7.3.9

Also tried:

  • With nodejs lts/Dubnium, encountered same error.
  • Tried npm i after force cleaning the npm cache.
  • Removing node and npm from the system and reinstalling everything.

Command executed: ng serve

The error is:

ERROR in ./src/assets/css/style.css (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embedded!./src/assets/css/style.css)
Module build failed (from ./node_modules/postcss-loader/src/index.js):
TypeError: Cannot read property 'type' of undefined
    at /home/akashj/workspace/projects/frontEnd/src/assets/css/style.css:1999:3
    at stringifyNode (/home/akashj/workspace/projects/frontEnd/node_modules/postcss-value-parser/lib/stringify.js:2:19)
    at Function.stringify (/home/akashj/workspace/projects/frontEnd/node_modules/postcss-value-parser/lib/stringify.js:45:10)
    at Gradient.colorStops (/home/akashj/workspace/projects/frontEnd/node_modules/autoprefixer/lib/hacks/gradient.js:505:26)
    at Gradient.oldWebkit (/home/akashj/workspace/projects/frontEnd/node_modules/autoprefixer/lib/hacks/gradient.js:398:10)
    at Gradient.replace (/home/akashj/workspace/projects/frontEnd/node_modules/autoprefixer/lib/hacks/gradient.js:91:30)
    at Gradient.add (/home/akashj/workspace/projects/frontEnd/node_modules/autoprefixer/lib/value.js:148:20)
    at Gradient.add (/home/akashj/workspace/projects/frontEnd/node_modules/autoprefixer/lib/hacks/gradient.js:572:35)
    at Gradient.process (/home/akashj/workspace/projects/frontEnd/node_modules/autoprefixer/lib/prefixer.js:157:16)
    at /home/akashj/workspace/projects/frontEnd/node_modules/autoprefixer/lib/processor.js:327:15
    at /home/akashj/workspace/projects/frontEnd/node_modules/postcss/lib/container.js:190:18
    at /home/akashj/workspace/projects/frontEnd/node_modules/postcss/lib/container.js:135:18
    at Rule.each (/home/akashj/workspace/projects/frontEnd/node_modules/postcss/lib/container.js:101:16)
    at Rule.walk (/home/akashj/workspace/projects/frontEnd/node_modules/postcss/lib/container.js:131:17)
    at /home/akashj/workspace/projects/frontEnd/node_modules/postcss/lib/container.js:148:24
    at Root.each (/home/akashj/workspace/projects/frontEnd/node_modules/postcss/lib/container.js:101:16)
    at Root.walk (/home/akashj/workspace/projects/frontEnd/node_modules/postcss/lib/container.js:131:17)
ℹ 「wdm」: Failed to compile.

For the whole console output of ng serve: https://pastebin.com/maHX3pCC

3
  • Can you post the contents of your style.css file? Commented Oct 25, 2019 at 11:00
  • @Isma, Hey, I found the cause and solved it! I will be adding the answer and the cause as I reach home. FYI: The issue was caused by an extra comma in a CSS declaration: background-image: linear-gradient(to right, #973a95, #055faa, ); Commented Oct 25, 2019 at 11:04
  • Follow the link which might help you. stackoverflow.com/a/67548425/11438030 Commented May 15, 2021 at 15:38

1 Answer 1

4

I resolved it. The CSS on that line (shown below) had a comma at the end and had no values after that. And postcss was throwing error due to that.

background-image: linear-gradient(to right, #973a95, #055faa, );

Removed the comma and it worked as expected

background-image: linear-gradient(to right, #973a95, #055faa);
Sign up to request clarification or add additional context in comments.

1 Comment

in my case the css had some content that seems to be invalid for raw-css-loader: /*# sourceMappingURL=style.css.map */. After removing this from css file, the loader has worked. This angular css parser needs to be improved and show a better message.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.