Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
sundowndev opened this issue Apr 23, 2018 · 34 comments · Fixed by JetBrains/ring-ui#277
Closed

Comments

@sundowndev
Copy link

sundowndev commented Apr 23, 2018

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

@alexander-akait
Copy link
Member

@sundowndev ls -l node_modules

@sundowndev
Copy link
Author

Of course the folders exist.

@alexander-akait
Copy link
Member

@sundowndev looks like you don't have node_modules/node-sass directory with package

@sundowndev
Copy link
Author

I have it. Here is his package.json :

{
  "_from": "node-sass@^4.8.3",
  "_id": "node-sass@4.8.3",
  "_inBundle": false,
  "_integrity": "sha512-tfFWhUsCk/Y19zarDcPo5xpj+IW3qCfOjVdHtYeG6S1CKbQOh1zqylnQK6cV3z9k80yxAnFX9Y+a9+XysDhhfg==",
  "_location": "/node-sass",
  "_phantomChildren": {
    "lru-cache": "4.1.2",
    "which": "1.3.0"
  },
  "_requested": {
    "type": "range",
    "registry": true,
    "raw": "node-sass@^4.8.3",
    "name": "node-sass",
    "escapedName": "node-sass",
    "rawSpec": "^4.8.3",
    "saveSpec": null,
    "fetchSpec": "^4.8.3"
  },
  "_requiredBy": [
    "#DEV:/"
  ],
  "_resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.8.3.tgz",
  "_shasum": "d077cc20a08ac06f661ca44fb6f19cd2ed41debb",
  "_spec": "node-sass@^4.8.3",
  "_where": "/var/www/VulcanoCMS",
  "author": {
    "name": "Andrew Nesbitt",
    "email": "andrewnez@gmail.com",
    "url": "http://andrew.github.com"
  },
  "bin": {
    "node-sass": "bin/node-sass"
  },
  "bugs": {
    "url": "https://github.com/sass/node-sass/issues"
  },
  "bundleDependencies": false,
  "dependencies": {
    "async-foreach": "^0.1.3",
    "chalk": "^1.1.1",
    "cross-spawn": "^3.0.0",
    "gaze": "^1.0.0",
    "get-stdin": "^4.0.1",
    "glob": "^7.0.3",
    "in-publish": "^2.0.0",
    "lodash.assign": "^4.2.0",
    "lodash.clonedeep": "^4.3.2",
    "lodash.mergewith": "^4.6.0",
    "meow": "^3.7.0",
    "mkdirp": "^0.5.1",
    "nan": "^2.10.0",
    "node-gyp": "^3.3.1",
    "npmlog": "^4.0.0",
    "request": "~2.79.0",
    "sass-graph": "^2.2.4",
    "stdout-stream": "^1.4.0",
    "true-case-path": "^1.0.2"
  },
  "deprecated": false,
  "description": "Wrapper around libsass",
  "devDependencies": {
    "coveralls": "^2.11.8",
    "eslint": "^3.4.0",
    "fs-extra": "^0.30.0",
    "istanbul": "^0.4.2",
    "mocha": "^3.1.2",
    "mocha-lcov-reporter": "^1.2.0",
    "object-merge": "^2.5.1",
    "read-yaml": "^1.0.0",
    "rimraf": "^2.5.2",
    "sass-spec": "^3.5.1",
    "unique-temp-dir": "^1.0.0"
  },
  "engines": {
    "node": ">=0.10.0"
  },
  "files": [
    "bin",
    "binding.gyp",
    "lib",
    "scripts",
    "src",
    "test",
    "vendor"
  ],
  "gypfile": true,
  "homepage": "https://github.com/sass/node-sass",
  "keywords": [
    "css",
    "libsass",
    "preprocessor",
    "sass",
    "scss",
    "style"
  ],
  "libsass": "3.5.2",
  "license": "MIT",
  "main": "lib/index.js",
  "name": "node-sass",
  "nodeSassConfig": {
    "binarySite": "https://github.com/sass/node-sass/releases/download"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/sass/node-sass.git"
  },
  "scripts": {
    "build": "node scripts/build.js --force",
    "coverage": "node scripts/coverage.js",
    "install": "node scripts/install.js",
    "lint": "eslint bin/node-sass lib scripts test",
    "postinstall": "node scripts/build.js",
    "prepublish": "not-in-install && node scripts/prepublish.js || in-install",
    "test": "mocha test/{*,**/**}.js"
  },
  "version": "4.8.3"
}

@alexander-akait
Copy link
Member

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

@sundowndev
Copy link
Author

sundowndev commented Apr 23, 2018

EDIT: not related with the original issue, fix below

getting this error at npm install

npm ERR! code ERR_STREAM_WRITE_AFTER_END
npm ERR! write after end

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-04-23T18_39_40_489Z-debug.log

log:

...
9755 verbose stack Error [ERR_STREAM_WRITE_AFTER_END]: write after end
9755 verbose stack     at writeAfterEnd (_stream_writable.js:241:12)
9755 verbose stack     at PassThrough.Writable.write (_stream_writable.js:291:5)
9755 verbose stack     at PassThrough.Writable.end (_stream_writable.js:576:10)
9755 verbose stack     at ReadEntry.entry.on (/root/.npm-global/lib/node_modules/npm/node_modules/pacote/lib/extract-stream.js:19:41)
9755 verbose stack     at ReadEntry.emit (events.js:185:15)
9755 verbose stack     at ReadEntry.emit (/root/.npm-global/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:287:25)
9755 verbose stack     at ReadEntry.[maybeEmitEnd] (/root/.npm-global/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:240:12)
9755 verbose stack     at ReadEntry.end (/root/.npm-global/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:153:27)
9755 verbose stack     at Unpack.[consumeBody] (/root/.npm-global/lib/node_modules/npm/node_modules/tar/lib/parse.js:210:13)
9755 verbose stack     at Unpack.[consumeChunkSub] (/root/.npm-global/lib/node_modules/npm/node_modules/tar/lib/parse.js:391:40)
9755 verbose stack     at Unpack.[consumeChunk] (/root/.npm-global/lib/node_modules/npm/node_modules/tar/lib/parse.js:362:30)
9755 verbose stack     at Unzip.(anonymous function).on.chunk (/root/.npm-global/lib/node_modules/npm/node_modules/tar/lib/parse.js:291:59)
9755 verbose stack     at Unzip.emit (events.js:180:13)
9755 verbose stack     at Unzip.emit (/root/.npm-global/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:287:25)
9755 verbose stack     at Unzip.write (/root/.npm-global/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:90:17)
9755 verbose stack     at Unzip.write (/root/.npm-global/lib/node_modules/npm/node_modules/tar/node_modules/minizlib/index.js:284:29)
9756 verbose cwd /var/www/VulcanoCMS
9757 verbose Linux 4.13.0-38-generic
9758 verbose argv "/usr/local/bin/node" "/root/.npm-global/bin/npm" "install"
9759 verbose node v9.10.1
9760 verbose npm  v5.8.0
9761 error code ERR_STREAM_WRITE_AFTER_END
9762 error write after end
9763 verbose exit [ 1, true ]

@alexander-akait
Copy link
Member

alexander-akait commented Apr 23, 2018

@sundowndev looks like a bug in npm, provide your node/npm version

@sundowndev
Copy link
Author

sundowndev commented Apr 23, 2018

Fixed with npm/npm#19989

but I get the same error on node-sass :

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

I'm on npm 5.8.0

@sundowndev
Copy link
Author

sundowndev commented Apr 23, 2018

Fixed by deleting node_modules, packages-lock.json, clear cache and reinstalling each package one by one on npm 5.6.0.

That's weird

@gencay
Copy link

gencay commented Apr 26, 2018

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

@NicolasLetellier
Copy link

NicolasLetellier commented Apr 27, 2018

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

@2WheelCoder
Copy link

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.

@abraham
Copy link

abraham commented May 3, 2018

On newer version of npm you can probably fix this with npm ci.

@simeyla
Copy link

simeyla commented May 8, 2018

This is going to be a popular topic with Angular 6 now requiring node 8.
Is there any benefit to running npm rebuild https://docs.npmjs.com/cli/rebuild for all packages - or is this just needed for sass?

@jamlfy
Copy link

jamlfy commented May 9, 2018

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",
  }

@searene
Copy link

searene commented May 12, 2018

I fixed it by downgrading node from 10.0.0 to 8.9.4

nvm install 8.9.4
nvm use 8.9.4

# set v8.9.4 as the default version
nvm alias default 8.9.4

@deftomat
Copy link

The same here, node 8.11.2 and nothing helps. I've tried to clear cache and upgrade all packages and still nothing.

@matiishyn
Copy link

Having exactly the same issue here
sass-loader doesn't work with node10
and another module requires node>9
What should I do?
plz help

@NigelThorne
Copy link

I was getting this issue, so I added some debug logging to sass-loader.

For me the problem was the following code:

function sassLoader(content) {
    if (asyncSassJobQueue === null) {
        let sass;
        let sassVersion;

        try {
            sass = require("node-sass");
            sassVersion = /^(\d+)/.exec(require("node-sass/package.json").version).pop();
        } catch (e) {
            throw new Error(   //  <---- this swallows the exception.
                ""+e.message+" "+require("node-sass/package.json").version+" - `sass-loader` requires `node-sass` >=4. Please install a compatible version."
            );
        }
   ...

I got the following errors...

Module build failed: Error: Missing binding f:\code\commitment_coach\code\vue-firebase-tutorial\node_modules\node-sass\vendor\win32-x64-48\binding.node       
Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 6.x                                                              
                                                                                                                                                              
Found bindings for the following environments:                                                                                                                
  - Windows 64-bit with Node.js 8.x                                                                                                                           

So for me... I just upgraded node to v8 and I was good.

@Oliboy50
Copy link

Oliboy50 commented May 19, 2018

@sundowndev reopen the issue please, this is a real issue

Module build failed: Error: `sass-loader` requires `node-sass` >=4. Please install a compatible version.
front_1  |     at Object.sassLoader (/home/node/app/node_modules/sass-loader/lib/loader.js:31:19)
# package-lock.json
...
    "sass-loader": {
      "version": "7.0.1",
...
    "node-sass": {
      "version": "4.9.0",
...

@Oliboy50
Copy link

Oliboy50 commented May 19, 2018

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

@kolkov
Copy link

kolkov commented May 20, 2018

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

@sundowndev
Copy link
Author

sundowndev commented May 20, 2018

Reopening the issue until it gets fixed.

Quick fix solutions (just choose one of these) :

@evilebottnawi please add proper labels

@sundowndev sundowndev reopened this May 20, 2018
@Oliboy50
Copy link

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 #563 (comment) for full output)

bobheadxi added a commit to ubclaunchpad/inertia that referenced this issue May 21, 2018
Some node dependencies, such as `node-sass`, are platform-specific - mounting `node_modules` leads to the Docker build using missing the correct platform dependencies.

See webpack-contrib/sass-loader#563 (comment)
@alexander-akait
Copy link
Member

Feel free to send a PR with showing original errors.

@Tenmak
Copy link

Tenmak commented May 22, 2018

Had to add "node-sass": "^4.9.0", to devDependencies to avoid the issue.

@mauriciopiber
Copy link

The point is, on any previous error during installation, even if install successful afterwards on retype, sass-node will fail. If occurs any, remove node_modules and run npm install from scratch instead of just fix the command and rerun.

@alexander-akait
Copy link
Member

Stop posting spam, just add +1 to post which help, thanks!

@iansamz
Copy link

iansamz commented May 25, 2018

npm rebuild node-sass worked for me too.

@tcrite
Copy link

tcrite commented May 27, 2018

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?

@antonevane
Copy link

antonevane commented May 29, 2018

I moved back to very old npm 3.10.10 that has been in our build for a while and it works like a charm.
No rebuild any more.

@alexander-akait
Copy link
Member

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

@sureshgopal01
Copy link

This issue came after I had upgraded my Node version from v6.10.2 to v8.11.2.
After doing npm rebuild node-sass the issue is gone.

@webpack-contrib webpack-contrib locked as spam and limited conversation to collaborators May 29, 2018
@alexander-akait
Copy link
Member

PR welcome to fix issue around error message

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.