我对上一个开发人员留下的一些代码有点问题。我试图让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)
完整的代码如下。我还没有看到任何人遇到过这样的插件这样的问题,所以不幸的是,我在调试节点方面有点离开我的联盟。我已经用Google搜索并修复了我遇到的很多错误,但我找不到这个错误。任何帮助都会非常感激!
// 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;
}
答案 0 :(得分:0)
把它扔到那里,你试过删除csscomb并安装最新版本吗?
此行config['rules-delimiter'] = 1