2
我有一个非常简单的咕噜声设置。唯一有效的插件是grunt-contrib-connect。这里是我的package.json文件:为什么grunt-contrib-connect找不到连接任务?
{
"name": "gruntApp",
"version": "0.1.0",
"description": "An application for testing Grunt.js",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-connect": "~0.3.0"
}
}
我gruntfile看起来是这样的:
module.exports = (grunt) ->
grunt.initConfig
pkg: grunt.file.readJSON 'package.json'
log:
start: 'Grunt is starting for application <%=pkg.name%> v<%=pkg.version%>'
end: 'Grunt is finishing'
grunt.registerMultiTask 'log', ->
grunt.log.writeln this.data
grunt.registerTask 'printConfig', ->
grunt.log.writeln JSON.stringify grunt.config(), null, 2
grunt.loadNpmTasks 'grunt-contrib-connect'
grunt.registerTask 'default', [
'log:start'
'log:end'
]
我的自定义任务的工作,但grunt connect
没有。这里是在控制台的输出:
$ grunt connect -v
Initializing
Command-line options: --verbose
Reading "Gruntfile.coffee" Gruntfile...OK
Registering Gruntfile tasks.
Reading package.json...OK
Parsing package.json...OK
Initializing config...OK
Registering "grunt-contrib-connect" local Npm module tasks.
Reading /Users/eric/Projects/gruntApp/node_modules/grunt-contrib-connect/package.json...OK
Parsing /Users/eric/Projects/gruntApp/node_modules/grunt-contrib-connect/package.json...OK
Loading "connect.js" tasks...OK
+ connect
Loading "Gruntfile.coffee" tasks...OK
+ default, log, printConfig
Running tasks: connect
Running "connect" task
>> No "connect" targets found.
Warning: Task "connect" failed. Use --force to continue.
Aborted due to warnings.
怎么了,哟?它看起来像检测到连接任务,但后来无法找到目标。我错过了什么?我是从这里的方向:https://github.com/gruntjs/grunt-contrib-connect#getting-started
我看到的唯一目标是'pkg'和'log'。没有'connect'目标。看看https://github.com/gruntjs/grunt-contrib-connect#usage-examples。 – 2013-04-24 17:05:08
我认为使用'grunt.loadNpmTasks'grunt-contrib-connect''会从该模块加载目标和任务。不是这样,我看到将init连接到initConfig解决了这个问题。 – SimplGy 2013-04-24 17:09:00