Diego Mijelshon
Diego Mijelshon

Reputation: 52725

Node/Gulp failing (can't load gulp-sass) outside Visual Studio

We are setting up Gulp with our VS project. When running the tasks from the VS Task Runner, they work flawlessly, but from the command line, it's failing.

Package.json:

{
  "name": "OurProject",
  "description": "OurProject",
  "repository": {
    "type": "git",
    "url": "https://github.com/something.git"
  },
  "private": true,
  "devDependencies": {
    "gulp": "^3.9.0",
    "gulp-cached": "^1.1.0",
    "gulp-coffee": "^2.3.1",
    "gulp-notify": "^2.2.0",
    "gulp-sass": "^2.0.4",
    "gulp-sourcemaps": "^1.5.2"
  }
}

Gulpfile.js (simplified):

var
    gulp = require('gulp'),
    sass = require('gulp-sass');

gulp.task('scss-compile', function () {
    return gulp
        .src("./Web/css/**/*.scss")
        .pipe(sass())
        .pipe(gulp.dest("./Web/css"));
});

Visual Studio claims to be using this command line:

cmd.exe /c gulp -b "C:\AbsoluteProjectPath" --color --gulpfile "C:\AbsoluteProjectPath\Gulpfile.js" scss-compile

Which doesn't work if I try it, because it can't find Gulp. So, I changed the current directory to C:\AbsoluteProjectPath and ran:

cmd.exe /c node_modules\.bin\gulp -b "C:\AbsoluteProjectPath" --color --gulpfile "C:\AbsoluteProjectPath\Gulpfile.js" scss-compile

And I got the following:

C:\AbsoluteProjectPath\node_modules\gulp-sass\node_modules\node-sass\lib\extensions.js:148
    throw new Error(['`libsass` bindings not found in ', binaryPath, '. Try re
          ^
Error: `libsass` bindings not found in C:\AbsoluteProjectPath\node_modules\gulp-sass\node_modules\node-sass\vendor\win32-ia32-14\binding.node. Try reinstalling `node-sass`?
    at Object.sass.getBinaryPath (C:\AbsoluteProjectPath\node_modules\gulp-sass\node_modules\node-sass\lib\extensions.js:148:11)
    at Object.<anonymous> (C:\AbsoluteProjectPaths\node_modules\gulp-sass\node_modules\node-sass\lib\index.js:16:36)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (C:\AbsoluteProjectPath\node_modules\gulp-sass\index.js:163:21)
    at Module._compile (module.js:460:26)

Now, that win32-ia32-14 folder doesn't exist. There is a win32-ia32-11 instead.

What might be happening here?

Upvotes: 1

Views: 595

Answers (1)

Diego Mijelshon
Diego Mijelshon

Reputation: 52725

This turned out to be Visual Studio using a different version of node.js that resolves to a different list of packages.

Upvotes: 1

Related Questions