17

Can you help me? I got this error when I hit ng s

ERROR in ./src/styles.scss (./node_modules/raw-loader!./node_modules/postcss-loader/lib??embedded!./node_modules/sass-loader/lib/loader.js??ref--14-3!./src/styles.scss)
Module build failed: Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.
    at Object.sassLoader (E:\Ibtikar\shop\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 (E:\Ibtikar\shop\node_modules\sass-loader\lib\loader.js:31:19)
ERROR in ./src/app/detail-view/detail-view.component.scss
Module build failed: Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.
    at Object.sassLoader (E:\Ibtikar\shop\node_modules\sass-loader\lib\loader.js:31:19)
ERROR in ./src/app/footer/footer.component.scss
Module build failed: Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.
    at Object.sassLoader (E:\Ibtikar\shop\node_modules\sass-loader\lib\loader.js:31:19)
ERROR in ./src/app/products/products.component.scss
Module build failed: Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.
    at Object.sassLoader (E:\Ibtikar\shop\node_modules\sass-loader\lib\loader.js:31:19)
ERROR in ./src/app/slider/slider.component.scss
Module build failed: Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.
    at Object.sassLoader (E:\Ibtikar\shop\node_modules\sass-loader\lib\loader.js:31:19)
ERROR in ./src/app/header/header.component.scss
Module build failed: Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.
    at Object.sassLoader (E:\Ibtikar\shop\node_modules\sass-loader\lib\loader.js:31:19)

flppv
  • 4,111
  • 5
  • 35
  • 54
FiryCode
  • 189
  • 1
  • 1
  • 9

9 Answers9

26

You need to run npm rebuild (or npm rb) in your project folder.

This command runs the npm build command on the matched folders. This is useful when you install a new version of node, and must recompile all your C++ addons with the new binary.

Source

flppv
  • 4,111
  • 5
  • 35
  • 54
9

This worked for me

npm install --save-dev node-sass
giveJob
  • 1,500
  • 3
  • 17
  • 29
6

npm rebuild node-sass --force : should work

Ram Ghadiyaram
  • 28,239
  • 13
  • 95
  • 121
4

npm rebuild --force - this will rebuild all packages. Only this worked for me

Ivan Frolov
  • 103
  • 6
1

Try rebuilding node-sass using npm rebuild node-sass and check if that fixes your issue.

SiddAjmera
  • 38,129
  • 5
  • 72
  • 110
Cpt Kitkat
  • 1,392
  • 4
  • 31
  • 50
1

working solution

Step 1 rm -rf node_modules it removes the directory recursively (the existing node modules, takes a min or two)

Step 2 npm install this will work for sure, i did try and it worked.

enter image description here

Community
  • 1
  • 1
Manoj
  • 692
  • 1
  • 10
  • 24
0

If you are facing this issue even after upgrading node-saas to version above 4 then follow below thread

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

Pradeep
  • 350
  • 1
  • 3
  • 13
  • Whilst this may theoretically answer the question, [it would be preferable](//meta.stackexchange.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Anton Menshov Jun 20 '19 at 06:44
0

Re-installing webpack solved the issue for me.

npm install --save-dev webpack

or, you can try :

npm rebuild node-sass
Abolfazl Roshanzamir
  • 12,730
  • 5
  • 63
  • 79
0

check for the supported version. As on date I had node 12.x installed on my machine and spent an hour running npm install node-sass and npm rebuild node-sass with --force and --save-dev hints.

Nothing worked until I uninstalled the node 12.x and installed node 10.x. So if you're hitting the same problem and could not get it to work, try following

  • Check if your Node version (Run node -v) if it's higher than 10.x
  • Uninstall the Node 12.x from your machine
  • Download and Install Node 10.x
  • Restart the console/editor (not required for all and may work without this step)
Sunny Sharma
  • 4,688
  • 5
  • 35
  • 73