question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Infinite styles compiling (create-react-app and node-sass)

See original GitHub issue

So we have a project which uses create-react-app and node-sass.

I have encountered this error many times over the last 2-3 months. I thought it was only happening to me, but now my colleague sometimes encounters this issue as well.


We have a standard setup from Adding a CSS Preprocessor (Sass, Less etc.).


Actual problem occurs when I edit the styles.scss and save them. Then an infinite compiling loop takes place. It’s seriously annoying and it uses a lot of memory as well.

Has anyone had encountered that problem and any ideas how to fix it?


package.json

{
  "name": "ParentPortal",
  "version": "0.1.10",
  "private": true,
  "eslintConfig": {
    "extends": "react-app",
    "env": {
      "jest": true
    }
  },
  "devDependencies": {
    "@octopusdeploy/octopackjs": "0.0.7",
    "bootstrap-sass": "^3.3.7",
    "enzyme": "^2.7.1",
    "flow-bin": "^0.41.0",
    "font-awesome": "^4.7.0",
    "node-sass": "^4.5.0",
    "npm-run-all": "^4.0.1",
    "react-addons-test-utils": "^15.4.2",
    "react-scripts": "^0.9.5",
    "react-test-renderer": "^15.4.2",
    "zip-dir": "^1.0.2"
  },
  "dependencies": {
    //
  },
  "scripts": {
    "build-css": "node-sass src/ -o src/",
    "watch-css": "npm run build-css && node-sass src/ -o src/ --watch",
    "start-js": "react-scripts start",
    "start": "npm-run-all -p watch-css start-js",
    "build": "npm run build-css && react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject",
    "flow": "flow",
    "publish": "node scripts/deploy.js"
  }
}

Example

create-react-app-issue

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (12 by maintainers)

github_iconTop GitHub Comments

13reactions
JasonGoemaatcommented, Apr 9, 2017

node-sass seems to detect the css file changing. I changed the script to only look for scss files and it worked for me:

"watch-css": "npm run build-css && node-sass src/*.scss -o src/ --watch --recursive",

1reaction
taomascommented, Jul 31, 2018

i had same problem in vscode, and resolved use by add code --usePolling --polling-interval 500

now my package.json script is

"build-css": "node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/",
"watch-css": "npm run build-css && node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive --usePolling --polling-interval 500"

it’s run successfully in vscode

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding a Sass Stylesheet - Create React App
To share variables between Sass files, you can use Sass's @use rule. For example, src/App.scss and other component style files could include ...
Read more >
How to use Sass and CSS Modules with create-react-app
How to use Sass and CSS Modules with create-react-app. A short yet detailed guide to styling components with create-react-app. For the most up- ......
Read more >
How to setup LESS with React without Ejecting
Implementing a LESS compiler into a Create React App project without ... since React 16.7 with a single additional package node-sass.
Read more >
Create-React-App v2 with Node-SASS and CSS Modules ...
When I change it to c it gives me this error. Failed to compile: Cannot find file: 'Portfolio.js' does not match the corresponding...
Read more >
Get Sass and Font Awesome up and running on your Create ...
Step 1 (if you haven't already): create your react app from the Terminal like so: ... "watch-css": "npm run build-css && node-sass-chokidar src/...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found