我有一个grunt任务,可以在javascript代码库上运行JSCS,一直都很正常,直到需要与使用最新、稳定版本的grunt、npm/node的构建服务器集成时才出现了问题。
在npm 1.XX.X下所有都运行得很好,但是在我升级到2.XX.X之后就出问题了。我尝试了最新的3.XX.X,但它以与2.XX.X相同的方式失败了。
我认为所需的关键部分是cli输出:
在npm 1.XX.X下所有都运行得很好,但是在我升级到2.XX.X之后就出问题了。我尝试了最新的3.XX.X,但它以与2.XX.X相同的方式失败了。
我认为所需的关键部分是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:
{
"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配置文件:
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
}
}
});
npm install
来安装项目吗? - kuzyn