Angular CLI 7.0.2 projects with SASS/SCSS fail to build properly
Bug Report or Feature Request (mark with an x)
- [X] bug report -> please search issues before submitting
- [ ] feature request
Command (mark with an x)
- [X] new (maybe?)
- [X] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Versions
macOS High Sierra
Node
v8.12.0
Angular
Angular CLI: 7.0.2
Node: 8.12.0
OS: darwin x64
Angular:
...
Package Version
------------------------------------------------------
@angular-devkit/architect 0.10.2
@angular-devkit/core 7.0.2
@angular-devkit/schematics 7.0.2
@schematics/angular 7.0.2
@schematics/update 0.10.2
rxjs 6.3.3
typescript 3.1.3
Repro steps
Generate a new project and set the style flag to sass or scss and then try to build the project.
https://github.com/JacobWDavidson/angularcliv7sassissue https://github.com/JacobWDavidson/angularcliv7scssissue
The log given by the failure
With SASS:
ERROR in ./src/styles.sass (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/lib??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):
TypeError: Cannot read property 'split' of undefined
at getRenderFuncFromSassImpl (/Users/jacobwdavidson/Documents/Projects/sasstest/node_modules/sass-loader/lib/loader.js:88:29)
at Object.sassLoader (/Users/jacobwdavidson/Documents/Projects/sasstest/node_modules/sass-loader/lib/loader.js:46:20)
With SCSS:
ERROR in ./src/styles.scss (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/lib??embedded!./node_modules/sass-loader/lib/loader.js??ref--14-3!./src/styles.scss)
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
TypeError: Cannot read property 'split' of undefined
at getRenderFuncFromSassImpl (/Users/jacobwdavidson/Documents/Projects/scsstest/node_modules/sass-loader/lib/loader.js:88:29)
at Object.sassLoader (/Users/jacobwdavidson/Documents/Projects/scsstest/node_modules/sass-loader/lib/loader.js:46:20)
Desired functionality
The build should complete without issue.
Mention any other details that might be useful
Easily reproducible with
ng new <projectname> style=scss | sass
cd <projectname>
ng build
I'm sorry, but we can't reproduce the problem following the instructions you provided.
Can you setup a minimal repro please?
You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.
This might be related to your directory structure so its really important to get an accurate repro to diagnose this.
@alan-agius4
Made two, one for sass, one for scss
https://github.com/JacobWDavidson/angularcliv7sassissue https://github.com/JacobWDavidson/angularcliv7scssissue
Having the same issue with 7.0.0, bump! Same specs as @JacobWDavidson and can reproduce it with a minimal repo.
@JacobWDavidson Tried both repositories and both appear to function properly. (ng build & ng build --prod).
Do you have a very old version of dart-sass installed by any chance?
@clydin I don't believe so. I tried adding a console log in the sass-loader to see what the issue may be
function getRenderFuncFromSassImpl(module) {
console.log(JSON.stringify(module));
const info = module.info;
const components = info.split("\t");
And it looks like the module object being passed in doesn't have this info property it's looking for:
{"version":"0.5.0","expansions":["-moz-","-webkit-"]}
I added another console log where the loader calls getRenderFuncFromSassImpl to log the options that it's pulling the implementation from and get this:
{ implementation:
{ version: '0.5.0',
expansions: [ '-moz-', '-webkit-' ],
collect: [Function],
render: [Function] },
fiber: undefined,
sourceMap: '/Users/jacobwdavidson/Documents/Projects/angularcliv7scssissue/sass.map',
precision: 8,
includePaths:
[ '/Users/jacobwdavidson/Documents/Projects/angularcliv7scssissue/src' ],
data: '/* You can add global styles to this file, and also import other style files */\n',
sourceMapRoot: '/Users/jacobwdavidson/Documents/Projects/angularcliv7scssissue',
omitSourceMapUrl: true,
sourceMapContents: true,
indentedSyntax: false,
importer: [ [Function] ] }
I put another higher up in the process to show the sass-loader being passed in via loader context and see this:
{
"path": "/Users/jacobwdavidson/Documents/Projects/angularcliv7scssissue/node_modules/sass-loader/lib/loader.js",
"query": "??ref--10-2",
"options": {
"implementation": {
"version": "0.5.0",
"expansions": [
"-moz-",
"-webkit-"
]
},
"sourceMap": true,
"precision": 8,
"includePaths": []
},
Attaching my yarn.lock too just in case that can provide additional context yarn.lock.zip
node-sass has a very old version of 0.5.0. Do you have node-sass installed manually?
@clydin I don't believe so.
angularcliv7scssissue$ node-sass -v
node-sass 4.9.3 (Wrapper) [JavaScript]
libsass 3.5.4 (Sass Compiler) [C/C++]
Looking through the attached yarn lock you'll also see that the sass-loader version installed is 7.1.0 so I'm not sure where that 0.5.0 version of anything is coming into play
globally? What happens when you run that outside a project?
I don't have it installed globally, so there shouldn't be a conflict.
It appears that versions of node-sass before 2.0.0 will exhibit the behavior described here.
This part:
"implementation": {
"version": "0.5.0",
"expansions": [
"-moz-",
"-webkit-"
]
}
is the result of the sass-loader performing a require('node-sass').
Where would it be finding that version of node-sass? Looking through the yarn lock, it's not installed there and I don't have it locally. Nothing is installed globally so it's not getting it there either.
Found the issue. There were node_modules under usr/local/lib, Users/
No problem at all. npm/node can be quite mysterious sometimes.
Got stuck on similar issue. It seams like node-sass searches upwards in dir structure and uses top most node_modules found. Ensuring that there are none above project directory fixed problem.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.