Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sass-loader requires node-sass >=4 even if that exist

Tags:

I executed a update to angular 6. And during ng serve -o I receive error that sass-loader expect node-sass. After run ng serve -o I receive:

ERROR in ./src/sass/styles.scss (./node_modules/raw-loader!./node_modules/postcss-loader/lib??embedded!./node_modules/sass-loader/lib/loader.js??ref--14-3!./src/sass/styles.scss)     Module build failed: Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.     at Object.sassLoader (node_modules\sass-loader\lib\loader.js:31:19) ERROR in ./src/app/app.component.scss Module build failed: Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.     at Object.sassLoader (node_modules\sass-loader\lib\loader.js:31:19) ERROR in x.component.scss Module build failed: Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.     at Object.sassLoader (\node_modules\sass-loader\lib\loader.js:31:19) ERROR in x.component.scss Module build failed: Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.     at Object.sassLoader (loader.js:31:19) ERROR in .x.component.scss Module build failed: Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.     at Object.sassLoader (node_modules\sass-loader\lib\loader.js:31:19) 

Obvisously I check everything (in my opinion) and I don't have idea what's going on.

Package.Json:

"devDependencies": { "@angular-devkit/build-angular": "~0.6.0", "@angular/cli": "6.0.0", "@angular/compiler-cli": "6.0.0", "@angular/language-service": "6.0.0", "@types/jasmine": "~2.8.3", "@types/jasminewd2": "~2.0.2", "@types/node": "~6.0.106", "codelyzer": "^4.0.1", "jasmine-core": "~2.8.0", "jasmine-spec-reporter": "~4.2.1", "karma": "~2.0.0", "karma-chrome-launcher": "~2.2.0", "karma-html-detailed-reporter": "^1.1.21", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "karma-phantomjs-launcher": "^1.0.4", "karma-teamcity-reporter": "^1.1.0", "phantomjs-prebuilt": "^2.1.16", "protractor": "~5.1.2", "node-sass": "^4.9.0", "sass-loader": "^7.0.1", "ts-node": "~4.1.0", "tslint": "~5.9.1", "typescript": "2.7.2" } 

dir -l node_modules says:

... 05/07/2018  08:53 AM    <DIR>          node-sass ... 05/07/2018  08:53 AM    <DIR>          sass-loader ... 

I executed:

npm rebuild node-sass  

and secod approach: I removed local node-module together with %User%\AppData\Roaming\npm-cache. then I removed lock file and execuded npm

npm cache clear --force npm install 

But still no success.

What do I miss ?

like image 741
Bartosz Kowalczyk Avatar asked May 07 '18 08:05

Bartosz Kowalczyk


People also ask

Does Sass loader require node-sass?

node. js - Sass-loader requires node-sass >=4 even if that exist - Stack Overflow. Stack Overflow for Teams – Start collaborating and sharing organizational knowledge.

Why node-Sass is required?

Node-sass is a library that provides binding for Node. js to libsass, the C version of the popular stylesheet preprocessor, Sass. It allows you to natively compile . scss files to css at incredible speed and automatically via a connect middleware.

Is Sass loader deprecated?

'node-sass' usage is deprecated and will be removed in a future major version. To opt-out of the deprecated behaviour and start using 'sass' uninstall 'node-sass'.


2 Answers

npm rebuild --force 

aslo helps

like image 197
Adham Amiin Avatar answered Oct 15 '22 08:10

Adham Amiin


I had same issue which I fixed using following steps:

  1. Delete package-lock.json file.
  2. Go to node_module folder and run rm -rf node_modules.
  3. Run npm install

The package-lock.json file will auto-update with the new dependencies version.

hope it helps.

like image 32
candidJ Avatar answered Oct 15 '22 08:10

candidJ