Node / NPM / Grunt failing on jscs (grunt-jscs)

I have a grumbling task that runs AOS based on javascript code, and it worked until it was time to integrate with the build server, which uses the latest stable versions of grunt, npm / node.

All this worked fine under npm 1.XX.X, but after I upgraded to 2.XX.X, it broke. I tried the latest versions of 3.XX.X, and this did not happen like 2.XX.X.

I assume that the necessary necessary parts are

cli output:

$ 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:

 { "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:

 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 } } }); 
+7
javascript gruntjs jscs
source share
4 answers

grunt-express There is a dependency in the project that causes this failure. grunt-express not been released for more than two years, so I decided to switch to grunt-contrib-connect and use it instead, and this solved my problem! Hope this helps anyone facing this issue.

0
source share

Just created a test project and I was able to reproduce the problem. He is in this line:

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

Use load-grunt-tasks instead:

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

Also run npm i --save-dev load-grunt-tasks and you will be fine!

+1
source share

Whenever I have problems related to node.js / npm updates, 10/10 times it was an erroneous dependency.

Try to grunt-jscs to a value of 2.5: https://www.npmjs.com/package/grunt-jscs

-one
source share

On the server: npm install jscs -g

-one
source share

All Articles