繁体   English   中英

无效的数据,块必须是缓冲区的字符串,而不是对象

[英]invalid data, chunk must be string of buffer, not object

我上一个开发人员遗留的一些代码有问题。 我正在尝试使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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM