Gruntfile.js - 未找到“默认”任务
Gruntfile.js - Task “default” not found
我正在尝试扩展此处构建的 D3 Calendar Viz 库:https://github.com/kamisama/cal-heatmap
并且我已经克隆了存储库。该代码使用 G运行t 作为构建过程,因此我在目录中安装了 G运行t-Cli 和 运行 npm install
,这有效。 运行 grunt
我得到一个错误:
Warning: Task "default" not found. Use --force to continue.
我已将 grunt.js 文件放入 http://esprima.org/demo/validate.html 并且它没有错误返回。我不明白为什么 g运行t 在这里不起作用。
这是 grunt.js 文件:
module.exports = function(grunt) {
"use strict";
var headerComment = "/*! <%= pkg.name %> v<%= pkg.version %> (<%= grunt.template.today() %>)\n" +
" * ---------------------------------------------\n" +
" * <%= pkg.description %>\n" +
" * <%= pkg.homepage %>\n" +
" * Licensed under the <%= pkg.license %> license\n" +
" * Copyright 2014 <%= pkg.author.name %>\n" +
" */\n";
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
jshint: {
options: {
jshintrc: ".jshintrc"
},
lib: {
src: ["src/<%= pkg.name %>.js"]
},
test: {
options: {
jshintrc: "test/.jshintrc"
},
src: ["test/test.js", "test/test-amd.js"]
}
},
csslint: {
base: {
src: "<%= pkg.name %>.css",
rules: {
"known-properties": false,
"box-sizing": false
}
}
},
uglify: {
options: {
banner: headerComment
},
base: {
files: {
"<%= pkg.name %>.min.js" : ["<%= pkg.name %>.js"]
}
}
},
qunit: {
options: {
"--web-security": "no",
coverage: {
src: ["src/*.js"],
instrumentedFiles: "temp/",
htmlReport: "report/coverage",
coberturaReport: "report/"
}
},
all: ["test/*.html"]
},
concat: {
options: {
banner: headerComment + "\n"
},
js: {
src: ["src/<%= pkg.name %>.js"],
dest: "<%= pkg.name %>.js"
},
test: {
src: ["test/src/function.js", "test/src/**/*.js"],
dest: "test/test.js"
}
},
coveralls: {
options: {
coverage_dir: "coverage/"
}
},
watch: {
scripts: {
files: "test/src/**/*.js",
tasks: ["concat:test"],
options: {
interrupt: true,
}
},
lint: {
files: "src/*.js",
tasks: ["jshint:lib"],
options: {
interrupt: true,
}
}
}
});
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-css");
grunt.loadNpmTasks("grunt-contrib-qunit");
grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-karma-coveralls");
grunt.loadNpmTasks("grunt-contrib-watch");
// TO RUN BEFORE COMMIT
// ====================
grunt.registerTask("quick-build", ["csslint", "jshint"]);
// Full build without version bump
grunt.registerTask("build", ["concat", "qunit", "csslint", "jshint", "uglify"]);
// FOR TRAVIS
// ==========
grunt.registerTask("travis", ["jshint", "csslint"]);
};
这里是 package.json 文件:
{
"name": "cal-heatmap",
"version": "3.5.2",
"description": "Cal-Heatmap is a javascript module to create calendar heatmap to visualize time series data",
"keywords": [
"calendar",
"graph",
"d3js",
"heat map"
],
"main": "cal-heatmap.min.js",
"directories": {
"test": "test"
},
"dependencies": {
"d3": ">= v3.0.6"
},
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-uglify": "~0.7.0",
"grunt-contrib-copy": "~0.7.0",
"grunt-contrib-jshint": "~0.11.0",
"grunt-contrib-concat": "~0.5.0",
"grunt-contrib-watch": "~0.6.1",
"grunt-contrib-qunit": "~0.5.2",
"grunt-css": "~0.5.4",
"grunt-replace": "~0.8.0",
"phantomjs": "~1.9.15",
"karma": "~0.12.31",
"karma-coverage": "~0.2.7",
"karma-qunit": "~0.1.4",
"karma-phantomjs-launcher": "~0.1.4",
"grunt-karma-coveralls": "~2.5.3",
"qunitjs": "~1.17.0",
"jquery": "~1.9.1"
},
"scripts": {
"test": "grunt travis --verbose; ./node_modules/karma/bin/karma start --single-run --browsers PhantomJS"
},
"repository": {
"type": "git",
"url": "https://github.com/kamisama/cal-heatmap.git"
},
"homepage": "https://github.com/kamisama/cal-heatmap",
"author": {
"name": "Wan Qi Chen",
"url": "http://www.kamisama.me"
},
"license": "MIT",
"gitHead": "e7bf798c210e0c25df9f6857bdb268001ef67fd1",
"volo": {
"dependencies": {
"d3": "d3"
}
},
"jam": {
"dependencies": {
"d3": ">=3.0.6"
}
},
"bugs": "https://github.com/kamisama/cal-heatmap/issues",
"github": "https://github.com/kamisama/cal-heatmap",
"categories": [
"Data",
"Visualization"
]
}
您需要定义默认任务,例如下面。
grunt.registerTask("default", [ "lint", "test", "coverage" ]);
我正在尝试扩展此处构建的 D3 Calendar Viz 库:https://github.com/kamisama/cal-heatmap
并且我已经克隆了存储库。该代码使用 G运行t 作为构建过程,因此我在目录中安装了 G运行t-Cli 和 运行 npm install
,这有效。 运行 grunt
我得到一个错误:
Warning: Task "default" not found. Use --force to continue.
我已将 grunt.js 文件放入 http://esprima.org/demo/validate.html 并且它没有错误返回。我不明白为什么 g运行t 在这里不起作用。
这是 grunt.js 文件:
module.exports = function(grunt) {
"use strict";
var headerComment = "/*! <%= pkg.name %> v<%= pkg.version %> (<%= grunt.template.today() %>)\n" +
" * ---------------------------------------------\n" +
" * <%= pkg.description %>\n" +
" * <%= pkg.homepage %>\n" +
" * Licensed under the <%= pkg.license %> license\n" +
" * Copyright 2014 <%= pkg.author.name %>\n" +
" */\n";
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
jshint: {
options: {
jshintrc: ".jshintrc"
},
lib: {
src: ["src/<%= pkg.name %>.js"]
},
test: {
options: {
jshintrc: "test/.jshintrc"
},
src: ["test/test.js", "test/test-amd.js"]
}
},
csslint: {
base: {
src: "<%= pkg.name %>.css",
rules: {
"known-properties": false,
"box-sizing": false
}
}
},
uglify: {
options: {
banner: headerComment
},
base: {
files: {
"<%= pkg.name %>.min.js" : ["<%= pkg.name %>.js"]
}
}
},
qunit: {
options: {
"--web-security": "no",
coverage: {
src: ["src/*.js"],
instrumentedFiles: "temp/",
htmlReport: "report/coverage",
coberturaReport: "report/"
}
},
all: ["test/*.html"]
},
concat: {
options: {
banner: headerComment + "\n"
},
js: {
src: ["src/<%= pkg.name %>.js"],
dest: "<%= pkg.name %>.js"
},
test: {
src: ["test/src/function.js", "test/src/**/*.js"],
dest: "test/test.js"
}
},
coveralls: {
options: {
coverage_dir: "coverage/"
}
},
watch: {
scripts: {
files: "test/src/**/*.js",
tasks: ["concat:test"],
options: {
interrupt: true,
}
},
lint: {
files: "src/*.js",
tasks: ["jshint:lib"],
options: {
interrupt: true,
}
}
}
});
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-css");
grunt.loadNpmTasks("grunt-contrib-qunit");
grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-karma-coveralls");
grunt.loadNpmTasks("grunt-contrib-watch");
// TO RUN BEFORE COMMIT
// ====================
grunt.registerTask("quick-build", ["csslint", "jshint"]);
// Full build without version bump
grunt.registerTask("build", ["concat", "qunit", "csslint", "jshint", "uglify"]);
// FOR TRAVIS
// ==========
grunt.registerTask("travis", ["jshint", "csslint"]);
};
这里是 package.json 文件:
{
"name": "cal-heatmap",
"version": "3.5.2",
"description": "Cal-Heatmap is a javascript module to create calendar heatmap to visualize time series data",
"keywords": [
"calendar",
"graph",
"d3js",
"heat map"
],
"main": "cal-heatmap.min.js",
"directories": {
"test": "test"
},
"dependencies": {
"d3": ">= v3.0.6"
},
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-uglify": "~0.7.0",
"grunt-contrib-copy": "~0.7.0",
"grunt-contrib-jshint": "~0.11.0",
"grunt-contrib-concat": "~0.5.0",
"grunt-contrib-watch": "~0.6.1",
"grunt-contrib-qunit": "~0.5.2",
"grunt-css": "~0.5.4",
"grunt-replace": "~0.8.0",
"phantomjs": "~1.9.15",
"karma": "~0.12.31",
"karma-coverage": "~0.2.7",
"karma-qunit": "~0.1.4",
"karma-phantomjs-launcher": "~0.1.4",
"grunt-karma-coveralls": "~2.5.3",
"qunitjs": "~1.17.0",
"jquery": "~1.9.1"
},
"scripts": {
"test": "grunt travis --verbose; ./node_modules/karma/bin/karma start --single-run --browsers PhantomJS"
},
"repository": {
"type": "git",
"url": "https://github.com/kamisama/cal-heatmap.git"
},
"homepage": "https://github.com/kamisama/cal-heatmap",
"author": {
"name": "Wan Qi Chen",
"url": "http://www.kamisama.me"
},
"license": "MIT",
"gitHead": "e7bf798c210e0c25df9f6857bdb268001ef67fd1",
"volo": {
"dependencies": {
"d3": "d3"
}
},
"jam": {
"dependencies": {
"d3": ">=3.0.6"
}
},
"bugs": "https://github.com/kamisama/cal-heatmap/issues",
"github": "https://github.com/kamisama/cal-heatmap",
"categories": [
"Data",
"Visualization"
]
}
您需要定义默认任务,例如下面。
grunt.registerTask("default", [ "lint", "test", "coverage" ]);