''node-sass' usage is deprecated and will be removed in a future major version

When I upgraded from Angular 8 to 11 I faced this warning

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

can anyone help me
Thanks in advance



Solution 1:[1]

The full error message is

'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'.

So, I think the only solution that you can try is obvious, just uninstall node-sass.

=> I already uninstalled it and tried ng serve and ng build --prod all is working fine.

FYI, I as a developer always have found this library node-sass as a pain in the head because of its incompatibility errors. I am happy that we don't have to use it and deal with its painful errors anymore.

Solution 2:[2]

Try replacing 'node-sass' with 'sass'

npm uninstall node-sass
npm i -S sass

Solution 3:[3]

$ npm uninstall node-sass

This will fix the following error also.

Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/resolve-url-loader/index.js):
Error: resolve-url-loader: CSS error
  source-map information is not available at url() declaration (found orphan CR, try removeCR option)

Solution 4:[4]

After uninstalling I was still getting the same error.

I had a look at the source code, turns out the check is quite fragile:

  try {
        sassImplementation = require('node-sass');
        wco.logger.warn(`'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'.`);
    }

Which means that, if you have node-sass installed globally, or in a parent directory somewhere, you'll get this warning.

To test this, make a new file in your project directory and run it with node:

const t = require('node-sass');

console.log(t);

If you don't get module_not_found, it means it's node_sass is being resolved. In my case I had node-sass installed under my user home directory.

Solution 5:[5]

currently (december 2021) it is installed with

npm install -g sass

https://sass-lang.com/install

Solution 6:[6]

You can replace node-sass with sass, which is the dart version of sass.

npm

npm uninstall node-sass
npm install sass

Yarn

yarn remove node-sass
yarn add sass

If you're using gulp, make sure to update your build script with the correct usage: https://www.npmjs.com/package/gulp-sass

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ahmed Shehatah
Solution 2 Henry Ecker
Solution 3 Edric
Solution 4 David
Solution 5 jmr85
Solution 6 robrecord