我在最后一位开发人员留下的一些代码上遇到了问题。我正在尝试使csscomb在sublime上运行并将其更新到可以与较新的软件包一起使用的程度。尝试在scss文件上运行包时遇到了此错误。完整错误粘贴在下面

CSScomb error:
net.js:658
throw new TypeError(
^

TypeError: Invalid data, chunk must be a string or buffer, not object
at Socket.write (net.js:658:11)
at combCSS (/Users/michaelr/Library/Application Support/Sublime Text 3/Packages/sublime-csscomb/csscomb.js:39:20)
at Socket.<anonymous> (/Users/michaelr/Library/Application Support/Sublime Text 3/Packages/sublime-csscomb/csscomb.js:18:5)


完整的代码如下。我还没有看到任何人遇到过这样的插件问题,所以不幸的是,在调试节点方面我有点不合时宜。我已经用谷歌搜索并修复了很多我遇到的错误,但是我找不到这个错误。任何帮助将不胜感激!

// Set up Variables
var CSScomb = require ('./node_modules/csscomb/lib/csscomb');
var comb = new CSScomb();

// Set encoding
process.stdin.resume();
process.stdin.setEncoding('utf8');

// Capture data
var input = '';
process.stdin.on('data', function (data) {
input += data;
});

// All data is read, run comb:
process.stdin.on('end', function() {
combCSS();
});

// Parse css
function combCSS() {
// Apply configuration:
comb.configure(getConfig());

// Parse css:
try {
    var combedCSS = comb.processString(input, {'syntax': 'scss'});
} catch (error) {
    // On error, output original css:
    process.stdout.write(input);
    // Show error message:
    process.stderr.write(error.message);
    console.log(error.message);
    process.exit(1);
}

// On success, output parsed css:
process.stdout.write(combedCSS);
process.exit();
}

function getConfig() {
var config = {};

// Use current project's root folder as a starting point.
// If no project is active, use current folder as a fallback:
var configpath = process.env.EDITOR_PROJECT_PATH ||   process.env.EDITOR_DIRECTORY_PATH;

// Search for custom config file recursively up to the home folder:
configpath = CSScomb.getCustomConfigPath(configpath + '/.csscomb.json');

try {
    // Try to load config file:
    config = require(configpath);
} catch (error) {
    // If no config file is available, use default config:
    config = getDefaultConfig();
}

return config;
}

function getDefaultConfig() {
var config = {};

var configZen = CSScomb.getConfig('zen');

// Copy only sort-order data:
config['sort-order'] = configZen['sort-order'];

// If sort-order is separated into sections, add an empty section at top:
if (config['sort-order'].length > 1) {
    config['sort-order'].unshift([]);
}

// Add sort-order info for SCSS, Sass and Less functions into the first section:
config['sort-order'][0].unshift('$variable', '$include', '$import');

// Add configuration that mimics most of the settings from Espresso:
config['block-indent']                    = "  ";
config['rules-delimiter']                 = 1
config['strip-spaces']                    = true;
config['always-semicolon']                = true;
config['vendor-prefix-align']             = true;
config['unitless-zero']                   = true;
config['leading-zero']                    = false;
config['quotes']                          = 'single';
config['color-case']                      = 'lower';
config['eof-newline']                     = true;
config['remove-empty-rulesets']           = true;
config['element-case']                    = 'lower';
config['color-shorthand']                 = false;
config['space-before-colon']              = '';
config['space-after-colon']               = ' ';
config['space-before-combinator']         = ' ';
config['space-after-combinator']          = ' ';
config['space-before-opening-brace']      = ' ';
config['space-after-opening-brace']       = '\n';
config['space-before-closing-brace']      = '\n';
config['space-before-selector-delimiter'] = '';
config['space-after-selector-delimiter']  = '\n';
config['space-between-declarations']      = '\n';

return config;
}

最佳答案

只是把它扔在那里,您是否尝试过删除csscomb并安装最新版本?

此外,您在此行config['rules-delimiter'] = 1上遇到语法错误

09-29 22:59