sass-loader: Error: `sass-loader` requires `node-sass` >=4 but node-sass is already at v4

ran encore dev --watch

get this error :

Module build failed: ModuleBuildError: Module build failed: Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.
    at Object.sassLoader (/var/www/VulcanoCMS/node_modules/sass-loader/lib/loader.js:31:19)
    at runLoaders (/var/www/VulcanoCMS/node_modules/webpack/lib/NormalModule.js:195:19)
    at /var/www/VulcanoCMS/node_modules/loader-runner/lib/LoaderRunner.js:364:11
    at /var/www/VulcanoCMS/node_modules/loader-runner/lib/LoaderRunner.js:230:18
    at runSyncOrAsync (/var/www/VulcanoCMS/node_modules/loader-runner/lib/LoaderRunner.js:143:3)
    at iterateNormalLoaders (/var/www/VulcanoCMS/node_modules/loader-runner/lib/LoaderRunner.js:229:2)
    at /var/www/VulcanoCMS/node_modules/loader-runner/lib/LoaderRunner.js:202:4
    at /var/www/VulcanoCMS/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:70:14
    at process._tickCallback (internal/process/next_tick.js:112:11)

but node-sass is at v4.8.3 in package.json :

{
    "devDependencies": {
        "@symfony/webpack-encore": "^0.20.1",
        "node-sass": "^4.8.3",
        "sass-loader": "^7.0.1"
    },
    "license": "UNLICENSED",
    "private": true,
    "scripts": {
        "dev-server": "encore dev-server",
        "dev": "encore dev",
        "watch": "encore dev --watch",
        "build": "encore production"
    },
    "dependencies": {
        "bootstrap": "^4.1.0",
        "jquery": "^3.3.1"
    }
}

already tried deleting node-modules folder and package-lock.json

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 34 (8 by maintainers)

Commits related to this issue

Most upvoted comments

I’ve also got the same error when upgrading node from v6.12 to v8.11.1 (now npm v5.6.0): Module build failed: Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.

This worked for me: npm rebuild node-sass

I had the exact same problem. It was because of a cached version of node-sass.

This solution worked for me:

  • Remove the node-sass from global npm-cache (For Windows users %userprofile%\AppData\Roaming\npm-cache)
  • Remove node-sass from your project’s node_modules dir
  • Do npm install to reinstall node-sass

@SundownDEV rm -rf node_modules && npm/yarn cache clear --force && npm/yarn install

npm rebuild node-sass is solution, don’t post spam please

npm rebuild node-sass worked for me too.

I think that the principal issue here is that sass-loader 7.x displays a wrong error message:

Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.

when node-sass 4.x is installed but unusable (e.g. when it is compiled for another environment)

Whereas sass-loader 6.x displays a clearer and more accurate error message:

Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 8.x
...
Run `npm rebuild node-sass --force` to build the binding for your current environment

(see https://github.com/webpack-contrib/sass-loader/issues/563#issuecomment-390435456 for full output)

Reopening the issue until it gets fixed.

Quick fix solutions (just choose one of these) :

  • rm -rf node_modules && npm/yarn cache clear --force && npm/yarn install
  • npm rebuild node-sass
  • yarn remove node-sass and yarn add node-sass
  • Downgrade npm to 5.6.0, delete node_modules, clear npm cache then npm install
  • Remove node-sass from global npm-cache, remove node-sass from node_modules dir, then npm install to reinstall it (reference:https://github.com/webpack-contrib/sass-loader/issues/563#issuecomment-384751280)

@evilebottnawi please add proper labels

npm rebuild node-sass fixed it for me. Thanks!

The soluctions… All time is fails!

  • Delete or clean cache the proyect is “new”, is starts!! no exist de node_modules
  • rebuild exist many problems in when run root. And "postinstall" : "npm rebuild". Well, thats is not a solution!

The versions

~$  node -v
v8.11.1
~$ npm -v
5.6.0
~$ cat /srv/myProyect/package.json
...
  "dependencies": {
...
    "@angular/common": "^6.0.0",
...
    "node-sass": "^4.9.0",
    "sass-loader": "^7.0.1",
  }

I’m having this same issue…which I was able to fix locally, but is there a workaround for this issue from a build server?

after downgrading to sass-loader@6.0.7, I had a clearer error:

front_1  | Module build failed: Error: Missing binding /home/node/app/node_modules/node-sass/vendor/linux-x64-57/binding.node
front_1  | Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 8.x
front_1  | 
front_1  | Found bindings for the following environments:
front_1  |   - OS X 64-bit with Node.js 8.x
front_1  | 
front_1  | This usually happens because your environment has changed since running `npm install`.
front_1  | Run `npm rebuild node-sass --force` to build the binding for your current environment.

Seems like my issue was to run npm install first on my Mac before building the Docker image based on Debian then binding node_volumes from the Mac to the Debian container using a volume

for information, to solve this, I edit my docker-compose.yaml file from

...
    volumes:
      - .:/home/node/app

to

...
    volumes:
      - .:/home/node/app
      - /home/node/app/node_modules

this makes the containerized app using its own node_modules directory instead of using the one from the host machine

I got this consistently even after clearing out node_modules and yarn’s cache. Upgraded from node 6.13.1 to 8.11.1, did yarn remove node-sass and and yarn add node-sass and everything worked again.