Has anybody done this successfully yet? I currently have node-sass installed in my CRA project and I'm trying to replace it with dart-sass but am experiencing difficulty because the CRA error output is telling me that I need to have node-sass installed. Is there any way to let the underlying CRA config know to use my installed dart-sass package instead of node-sass?
3 Answers
There is this closed issue on CRA repository, so you probably can easily migrate from node-sass to Dart Sass just running a few commands.
First of all check your yarn.lock or package-lock.json to know if the version of the sass-loader that your react-scripts depends on is 7.2.0 or later.
If so, all that you need is run the following commands:
yarn remove node-sass
yarn add sass
In my case after that I had to remove the node_modules directory and ran the yarn install again due to an issue stating the app.
Notes:
- The
react-scriptsversion I'm using is 4.0.0 - The npm lib for Dart Sass is
sass - The use of
node-sassis deprecated since 26 October 2020
6 Comments
node-sass and add sass. I added it as a devDependency, this could negatively affect production behaviour? Thanks!dependencies: create-react-app.dev/docs/adding-a-sass-stylesheet Thera are also a lot of issues questioning the fact of adding dependencies directly on dependencies, and it seems adding dependencies to devDependencies may lead build to fail in some cases. Check this issue for more info: github.com/facebook/create-react-app/issues/2696SassError: Expected "n". ╷ 645 │ .MuiSlider-markLabel.MuiSlider-markLabelActive:nth-last-child(){ ..} . I tried deleting node_modules and npm install again after that, but it didn't work for me. Can you help?.MuiSlider-markLabel.MuiSlider-markLabelActive:nth-last-child starting on line 645, in order check this error is fix. If so, them you can try to narrowing the commented code until you find the exact point of failure.react-scripts version first (I was on 3.0.x and had to update to 4.0.3). Older versions may not recognize the sass lib. It's pretty easy to upgrade, they have instructions on their releases page. Just install the latest version with --exact and probably also reinstall node_modules.If you are using npm > 6.9 you can create an alias like so
npm install node-sass@npm:sass
it will install dart-sass and you will be able to keep your CRA configuration.
6 Comments
npm outdated command for some reason!yarn add node-sass@yarn:sass; It seemed to work for me.