简体   繁体   English

节点/ NPM / Grunt在jscs上失败(grunt-jscs)

[英]Node/NPM/Grunt failing on jscs (grunt-jscs)

I have a grunt task that runs JSCS on a javascript code base and it was working until it came time to integrate with the build server which is using latest, stable versions of grunt, npm/node. 我有一个在javascript代码库上运行JSCS的繁琐任务,它一直在工作,直到与使用最新,稳定版本的grunt,npm / node的构建服务器集成。

This all ran fine under npm 1.XX.X but after i upgraded to 2.XX.X it broke. 这一切都在npm 1.XX.X下运行良好,但在我升级到2.XX.X后它就破了。 I tried latest, 3.XX.X, and that failed in the same fashion as 2.XX.X. 我尝试了最新的3.XX.X,但失败的方式与2.XX.X相同。

I assume the pertinent parts needed are the 我假设所需的相关部分是

the cli output: cli输出:

$ node -v
v5.2.0

$ npm -v
3.3.12

$ grunt --version
grunt-cli v0.1.13
grunt v0.4.5

$ grunt jscs
Loading "jscs.js" tasks...ERROR
>> TypeError: fn.call is not a function
Warning: Task "jscs" not found. Use --force to continue.

Aborted due to warnings.

package.json: 的package.json:

{
"name": "Javascript",
  "version": "1.0.0",
  "private": true,
  "devDependencies": {
    "grunt": "~0.4.5",
    "matchdep": "^0.3.0",
    "grunt-contrib-watch": "~0.6.1",
    "grunt-express": "~1.4.1",
    "grunt-open": "~0.2.3",
    "grunt-chmod": "~1.0.3",
    "grunt-contrib-jshint": "~0.11.3",
    "grunt-contrib-uglify": "~0.10.0",
    "karma": "~0.13.15",
    "grunt-karma": "~0.12.1",
    "jasmine-core": "~2.3.4",
    "karma-jasmine": "~0.3.6",
    "phantomjs": "~1.9.18",
    "karma-phantomjs-launcher": "~0.2.1",
    "angular-mocks": "~1.2.28",
    "jquery": "~2.1.4",
    "underscore": "~1.8.3",
    "grunt-contrib-clean": "~0.6.0",
    "karma-coverage": "~0.5.3",
    "grunt-jscs": "~2.3.0",
    "grunt-contrib-concat": "~0.5.1"
  }
}

Gruntfile.js config: Gruntfile.js配置:

module.exports = function (grunt) {
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

grunt.initConfig({
    .....
    jscs: {
        src: [
            'gruntfile.js',
            '<%= sourceFolder %>/**/*.js',
            '!<%= sourceFolder %>/angular/**',
            '!<%= sourceFolder %>/es5-shim/**',
            '!<%= sourceFolder %>/**/*[.-]min.js',
            '!<%= sourceFolder %>/respond/*.js',
            '!<%= sourceFolder %>/angular-ui-bootstrap/*.js',
            '!<%= sourceFolder %>/analytics/angulartics*.js'
        ],
        options: {
            config: '.jscsrc',
            fix: true
        }
    }
});

Just created a test project and I was able to reproduce the issue. 刚刚创建了一个测试项目,我就能够重现这个问题。 It's in this line: 它在这一行:

require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

Use load-grunt-tasks instead: 请改用load-grunt-tasks

require('load-grunt-tasks')(grunt);

Also run npm i --save-dev load-grunt-tasks and you're good to go! 还运行npm i --save-dev load-grunt-tasks ,你很高兴!

grunt-express project holds a dependency that causes this failure. grunt-express项目拥有导致此失败的依赖项。 grunt-express has not been released in over 2 years therefor i've chosen to move to grunt-contrib-connect and use that instead and this solved my issue! grunt-express还没有在2年多的时间里发布,因此我选择转移到grunt-contrib-connect并使用它,这解决了我的问题! Hope it helps anyone who runs into this issue. 希望它可以帮助任何遇到这个问题的人。

Whenever I have build problems related to node.js/npm upgrades, 10/10 times it has been a faulty dependency. 每当我构建与node.js / npm升级相关的问题时,10/10次它都是一个错误的依赖。

Try bumping the grunt-jscs dependency to 2.5: https://www.npmjs.com/package/grunt-jscs 尝试将grunt-jscs依赖项碰撞到2.5: httpsgrunt-jscs

在服务器上: npm install jscs -g

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

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