admin管理员组文章数量:1302431
few moments ago I installed Angular Cli 7 and started clean project by
ng new my-app
I selected prepiler SASS for css, but when I'm editing file styles.sass then is not working, my styles.sass looks like this
h1 { color: red }
but ng serve show this message
Failed to pile.
./src/styles.sass (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embedded!./node_modules/sass-loader/lib/loader.js??ref--14-3!./src/styles.sass) Module build failed (from ./node_modules/sass-loader/lib/loader.js):
h1 { ^ Invalid CSS after "h1 {": expected "}", was "{" in /Users/a/Documents/angular-projects/my-app/src/styles.sass (line 1, column 5)
how to fix it? and why that's happen?
few moments ago I installed Angular Cli 7 and started clean project by
ng new my-app
I selected prepiler SASS for css, but when I'm editing file styles.sass then is not working, my styles.sass looks like this
h1 { color: red }
but ng serve show this message
Failed to pile.
./src/styles.sass (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embedded!./node_modules/sass-loader/lib/loader.js??ref--14-3!./src/styles.sass) Module build failed (from ./node_modules/sass-loader/lib/loader.js):
h1 { ^ Invalid CSS after "h1 {": expected "}", was "{" in /Users/a/Documents/angular-projects/my-app/src/styles.sass (line 1, column 5)
how to fix it? and why that's happen?
Share asked Oct 25, 2018 at 12:23 axlplaxlpl 4831 gold badge8 silver badges18 bronze badges 1- try to create like ng new my-app --style=scss – Rahul Dudharejiya Commented Oct 25, 2018 at 12:26
4 Answers
Reset to default 3The CLI offers a mand line flag to change your style when creating a new project with
ng new my-app --style=scss
As you can see, the extension is
.scss
, not.sass
(at least for the syntax you're using, which is LESS)You are missing a semicolon
h1 { color: red; }
Remember to update your
angular.json
and ponent files accordingly if you don't reecreate a new project to resolve that
Could be because you upgraded your node. Try installing node-sass
npm install node-sass
More details about node-sass on https://www.npmjs./package/node-sass
dude ... I think your sintaxe maybe be wrong, look at https://sass-lang./guide you shoulding use
h1
color: red,
align: center
...
Had the same problem, tried everything including reinstalling all the packages and node itself and none of them helped.
Finally the project was cloned to D:\somefolder instead of the Desktop where I was cloning before. Then it piled without any issues and worked fine.
本文标签: javascriptAngular CLI 7 Sass failed to compileStack Overflow
版权声明:本文标题:javascript - Angular CLI 7: Sass failed to compile - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741679543a2392083.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论