102

I'm using VS2015 and Gulp. I open the Task Runner Explorer and hit refresh, and this shows up in the log:

Failed to run "C:\Projects\Test\Gulpfile.js"...
cmd.exe /c gulp --tasks-simple
Error: `libsass` bindings not found in C:\Projects\Test\node_modules\gulp-sass\node_modules\node-sass\vendor\win32-ia32-11\binding.node. Try reinstalling `node-sass`?
    at Object.sass.getBinaryPath (C:\Projects\Test\node_modules\gulp-sass\node_modules\node-sass\lib\extensions.js:148:11)
    at Object.<anonymous> (C:\Projects\Test\node_modules\gulp-sass\node_modules\node-sass\lib\index.js:16:36)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (C:\Projects\Test\node_modules\gulp-sass\index.js:163:21)
    at Module._compile (module.js:456:26)

So I try to run cmd.exe /c gulp --tasks-simple in PowerShell, in the same directory, and it works fine - it returns a list of tasks.

I'm also able to run my SASS-related tasks just fine, so I'm not sure why this is complaining about SASS when it's being run via VS but not directly on the command line.

5 Answers 5

316

I had the same problem migrating from VS2013 recently.

As Josh noted in his comment here Visual Studio 2015 ships with an older version of Node. In case you don't want to get stuck with whatever version of Node is built into Visual Studio, you can tell it to use the version you have already installed.

  • Go to: Tools > Options > Projects and Solutions > External Web Tools
  • Reorder so that $(PATH) is above $(DevEnvDir)\Extensions\Microsoft\Web Tools\External

This also applies to other tools like Grunt, Bower and Gulp.

Found this solution by Mads Kristensen here.

For Visual Studio 2017, we can find the setting at
Tools > Options > Projects and Solutions > Web Package Management > External Web Tools

9
  • 1
    Yep I ended up doing the same thing but forgot to come back here and add a one-million-and-one-th comment. Thanks!
    – Josh M.
    Jul 16, 2015 at 2:14
  • 1
    Someone get this solution into the error message! #grins# Aug 22, 2016 at 6:52
  • 1
    In VS2017 it's Tools > Options > Projects and Solutions > Web Package Management > External Web Tools Sep 10, 2017 at 19:56
  • 5
    In VS2017, you also need to put $(PATH) above $(VSINSTALLERDIR)\Web\External Nov 12, 2017 at 0:38
  • 1
    In VS2017, I also had to move $(PATH) above .\node_modules\.bin (Basically, I had to move it to the top.)
    – Doug
    Nov 14, 2017 at 21:26
7

It seems gulp-sass searchs node-sass in a different location. Here is a temporary solution.

  1. create a new directory named win32-ia32-11 inside c:\Projects\Test\node_modules\gulp-sass\node_modules\node-sass\vendor\

  2. Goto https://github.com/sass/node-sass-binaries and download win32-ia32-11_binding.node.

  3. Copy win32-ia32-11_binding.node file to c:\Projects\Test\node_modules\gulp-sass\node_modules\node-sass\vendor\win32-ia32-11\ and rename it to binding.node

Visual Studio Gulp - Task Runner

6
  • 1
    Ah, I see. It appears I've installed the 64-bit version of all of my node modules, but it must be running in a 32-bit context since I'm in VS which is 32-bit. I guess. And I can't seem to find a good way to force installation of 32-bit packages. Kind of surprised I couldn't find more info on this topic, seems lots of people would likely have this issue.
    – Josh M.
    Jul 10, 2015 at 1:19
  • And I also couldn't find a good way to force NPM to install the ia32 version of all packages. I tried creating a .npmrc file with the appropriate config option, but no luck. Even running npm install within a 32-bit PS console, the 64bit versions are still being installed.
    – Josh M.
    Jul 10, 2015 at 13:47
  • This is crazy. I installed the 32bit version of node instead, and then reinstalled all my packages and this time the 32bit version of node-sass is installed, but the binding is win32-ia32-14 instead of win32-ia32-11 -- which for some reason is what libsass is looking for...
    – Josh M.
    Jul 10, 2015 at 14:03
  • BTW your solution works but I see it as a bandaid - I don't want this to be a step other developers have to take when they're firing this up for the first time!
    – Josh M.
    Jul 10, 2015 at 14:04
  • 1
    Argh, that's 0.10.31 32bit: nodejs.org/dist/v0.10.31/node-v0.10.31-x86.msi
    – Josh M.
    Jul 10, 2015 at 15:16
2

I have tried all above solutions but it doesn't work and I found another solution here.

You have to force Visual Studio run with your Node.js version:

  1. Go to Tools > Options in Visual Studio 2015
  2. Go to Projects and Solutions > External Web Tools
  3. Add the following path: C:\Program Files\nodejs
0
1

The only solution that solved my problem was re-installing NPM Task Runner. You can download it from following link at marketplace.
https://marketplace.visualstudio.com/items?itemName=MadsKristensen.NPMTaskRunner

0

node-sass runs an install script to download the required binary. If there are no environment variables, .npmrc variables or process arguments set then the binary is determined by using the current process platform, architecture and Node ABI version. Therefore, if you run node install in one application and then try to run node-sass in an application with a different platform/architecture/ABI, the binary won't have been downloaded. The solution is to manually download the binary or to fix the binary version using an environment variable (SASS_BINARY_NAME) or a .npmrc variable (sass_binary_name)

You can see the logic for this in the getBinaryPath function in node-sass\lib\extensions.js

See also: Node Sass could not find a binding for your current environment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.