8

我是 gulp 的新手,并试图使用它。当我尝试使用时出现此错误gulp-jscs

'default' errored after 98 ms
[16:58:00] TypeError: Object.keys called on non-object
    at Function.keys (native)
    at NodeConfiguration.Configuration._throwNonCamelCaseErrorIfNeeded (/home/kbadr/Node_Projects/demo/membership/node_modules/gulp-jscs/node_modules/jscs/lib/config/configuration.js:440:12)
    at NodeConfiguration.Configuration.load (/home/kbadr/Node_Projects/demo/membership/node_modules/gulp-jscs/node_modules/jscs/lib/config/configuration.js:51:10)
    at StringChecker.configure (/home/kbadr/Node_Projects/demo/membership/node_modules/gulp-jscs/node_modules/jscs/lib/string-checker.js:66:29)
    at Checker.configure (/home/kbadr/Node_Projects/demo/membership/node_modules/gulp-jscs/node_modules/jscs/lib/checker.js:26:39)
    at module.exports (/home/kbadr/Node_Projects/demo/membership/node_modules/gulp-jscs/index.js:31:11)
    at Gulp.<anonymous> (/home/kbadr/Node_Projects/demo/membership/gulpfile.js:22:15)
    at module.exports (/home/kbadr/Node_Projects/demo/membership/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/home/kbadr/Node_Projects/demo/membership/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/home/kbadr/Node_Projects/demo/membership/node_modules/gulp/node_modules/orchestrator/index.js:214:10

这是我的gulpfile

var gulp = require('gulp');
var jscs = require('gulp-jscs');

gulp.task('default', function () {
    return gulp.src('src/app.js')
        .pipe(jscs());
});
4

3 回答 3

8

如果 jscs 没有对您的 .jscsrc 的读取权限或者它不存在,这似乎会发生。从旧的 git repro 复制并粘贴它后,这发生在我身上。要解决此问题,请使用文本编辑器打开文件并重新保存,接受覆盖提示并以“。”开头。(例如 .jscsrc)再次运行您的任务,它将完成。

于 2015-02-21T15:07:48.513 回答
2

我遇到了同样的问题:“无法在/Desktop/node/My_Project_Name/.jscsrc 加载 JSCS 配置文件,输入意外结束......”

我能够通过首先检查文件是否存在于我的项目的根目录中来解决问题。在终端运行这个命令: ls -ld .?*

该文件从未为我创建,因此我创建了.jscsrc文件,然后添加了以下代码:

{
 "excludeFiles": ["node_modules/**", "bower_components/**"],

"requireCurlyBraces": [
    "if",
    "else",
    "for",
    "while",
    "do",
    "try",
    "catch"
],
"requireOperatorBeforeLineBreak": true,
"requireCamelCaseOrUpperCaseIdentifiers": true,
"maximumLineLength": {
  "value": 100,
  "allowComments": true,
  "allowRegex": true
},
"validateIndentation": 4,
"validateQuoteMarks": "'",

"disallowMultipleLineStrings": true,
"disallowMixedSpacesAndTabs": true,
"disallowTrailingWhitespace": true,
"disallowSpaceAfterPrefixUnaryOperators": true,
"disallowMultipleVarDecl": null,

"requireSpaceAfterKeywords": [
  "if",
  "else",
  "for",
  "while",
  "do",
  "switch",
  "return",
  "try",
  "catch"
],
"requireSpaceBeforeBinaryOperators": [
    "=", "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=",
    "&=", "|=", "^=", "+=",

    "+", "-", "*", "/", "%", "<<", ">>", ">>>", "&",
    "|", "^", "&&", "||", "===", "==", ">=",
    "<=", "<", ">", "!=", "!=="
],
"requireSpaceAfterBinaryOperators": true,
"requireSpacesInConditionalExpression": true,
"requireSpaceBeforeBlockStatements": true,
"requireLineFeedAtFileEnd": true,
"disallowSpacesInsideObjectBrackets": "all",
"disallowSpacesInsideArrayBrackets": "all",
"disallowSpacesInsideParentheses": true,

"validateJSDoc": {
    "checkParamNames": true,
    "requireParamTypes": true
},

"disallowMultipleLineBreaks": true,

"disallowCommaBeforeLineBreak": null,
"disallowDanglingUnderscores": null,
"disallowEmptyBlocks": null,
"disallowMultipleLineStrings": null,
"disallowTrailingComma": null,
"requireCommaBeforeLineBreak": null,
"requireDotNotation": null,
"requireMultipleVarDecl": null,
"requireParenthesesAroundIIFE": true
}

将此文件保存到项目的根目录,然后再次运行 gulp task 命令,它应该可以工作。

于 2015-08-13T18:43:39.030 回答
0

更新了 bower.json 中对 ngCordova 的依赖并解决了问题!!!

于 2016-04-17T02:29:48.017 回答