Node / Gulp在Visual Studio外部失败(无法加载gulp-sass)

时间:2015-08-12 13:12:36

标签: node.js npm gulp visual-studio-2015 gulp-sass

我们正在与我们的VS项目建立Gulp。从VS Task Runner运行任务时,它们可以完美地工作,但是从命令行开始,它会失败。

的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(简化):

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 声明使用此命令行:

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

如果我尝试它,它不起作用,因为它无法找到Gulp。所以,我将当前目录更改为C:\AbsoluteProjectPath并运行:

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

我得到了以下内容:

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)

现在,win32-ia32-14文件夹不存在。而是win32-ia32-11

这里可能会发生什么?

1 个答案:

答案 0 :(得分:1)

结果是使用不同版本的node.js的Visual Studio解析为不同的包列表。