我正在使用grunt创建本地服务器。但是当我运行grunt命令时,它无法找到连接任务。请有人帮忙解决这个问题。
注意:我搜索了stackoverflow和google。
Grunt JS档案
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON,
clean: ["lib/tictactoe/build"],
connect:{
all:{
options:{
port:9000,
hostname:'localhost'
}
}
}
})
grunt.loadNpmTasks('grunt-contrib-clean','grunt-contrib-connect');
grunt.registerTask('default', ['clean','connect']);
}
的package.json
{
"name": "gruntang",
"private": true,
"devDependencies": {
"autoprefixer-core": "^5.2.1",
"grunt": "^0.4.5",
"grunt-angular-templates": "^0.5.7",
"grunt-concurrent": "^1.0.0",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-compass": "^1.0.0",
"grunt-contrib-concat": "^0.5.0",
"grunt-contrib-connect": "^0.9.0",
"grunt-contrib-copy": "^0.7.0",
"grunt-contrib-cssmin": "^0.12.0",
"grunt-contrib-htmlmin": "^0.4.0",
"grunt-contrib-imagemin": "^1.0.0",
"grunt-contrib-jshint": "^0.11.0",
"grunt-contrib-uglify": "^0.7.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-filerev": "^2.1.2",
"grunt-google-cdn": "^0.4.3",
"jshint-stylish": "^1.0.0"
},
"engines": {
"node": ">=0.10.0"
}
}
答案 0 :(得分:1)
您需要单独拨打loadNpmTasks
:
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-connect');
您只能使用loadNpmTasks
一次加载一个插件。