【问题标题】:gulp-compass fileName error on windowsWindows上的gulp-compass文件名错误
【发布时间】:2015-03-19 01:26:44
【问题描述】:

我是第一次使用 compass/susy,我想使用 liveReload 来避免重新加载。

我在安装 compass 后安装了 gulp-compass,但显然它返回的 src 文件路径不带引号。

这是我的 gulpfile.js:

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

// Compass
gulp.task('compass', function () {
    gulp.src('sass/*.sass')
    .pipe(compass({
        config_file: './config.rb',
        css: 'css',
        sass: 'sass',
        require: ['susy']
    }))
    .on('error', console.error.bind(console))
    .pipe(gulp.dest('temp/'));
});

它返回以下错误:

Starting 'compass'...
'E:\Program' not recognizes as a internal or external command [...]

{ [Error: Compass failed]
  message: 'Compass failed',
  fileName: 'E:\\Program Files\\wamp\\[...]\\style.sass',
  showStack: false,
  showProperties: true,
  plugin: 'gulp-compass',
  __safety: { toString: [Function] } }

所以我收集到的是源文件的路径(在我的 Windows 中,位于“E:\Program Files[...]”内)不带引号返回,使得第一个空白字符看起来像路的尽头,对吧?

如何将其放在引号内?顺便说一句,我正在做所有这些工作,所以我可以将 gulp 与指南针一起使用。

【问题讨论】:

    标签: windows sass gulp compass


    【解决方案1】:

    我遇到了同样的问题。

    在第 78 行的 node_modules\gulp-compass\lib\compass.js 中,一切都出错了:

    options.push(opts.project.replace(/\\/g, '/'));
    

    不知何故,当我注释掉这一行时,就没有更多的错误了。用 /somehow 替换 \ 会导致路径 Program Files 中的空格失败。 这是第 76 到 81 行:

    options.push(opts.task);
      if (process.platform === 'win32') {
        // options.push(opts.project.replace(/\\/g, '/')); // <-- this line causes the error
      } else {
       options.push(opts.project);
    }
    

    所以,这暂时解决了问题。

    但是应该有更好的方法来解决这个问题(至少在 node_modules 文件夹之外)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-15
      • 2016-04-13
      • 1970-01-01
      • 2023-03-13
      • 1970-01-01
      • 2017-03-11
      • 2016-07-18
      • 1970-01-01
      相关资源
      最近更新 更多