新的咕噜声 - 警告:任务" concat,uglify"未找到

时间:2015-06-29 16:39:55

标签: javascript node.js gruntjs grunt-contrib-concat grunt-contrib-uglify

正如标题所说,我是Grunt的新手。我正在关注位于http://24ways.org/2013/grunt-is-not-weird-and-hard/的教程。这是一个较旧的教程,但大多数似乎工作相同。我已经安装了" grunt-contrib-concat"和" grunt-contrib-uglify"并且可以单独运行。但是当我运行grunt时,我收到以下错误:Warning: Task "concat, uglify" not found. Use --force to continue. Aborted due to errors.我一直在环顾四周,似乎无法弄明白。我的文件如下:

Gruntfile.js:

module.exports = function(grunt) {

            // 1. All configuration goes here 
            grunt.initConfig({
                pkg: grunt.file.readJSON('package.json'),

                concat: {

                    dist: {
                        src: [
                            'js/libs/*.js', // All JS in the libs folder
                            'js/controls.js', // This specific file
                        ],
                        dest: 'dist/built.js',
                    }
                },

                uglify: {
                    build: {
                        src: 'js/build/production.js',
                        dest: 'js/build/production.min.js',
                    }
                },

            });

            // 3. Where we tell Grunt we plan to use this plug-in.
            grunt.loadNpmTasks('grunt-contrib-concat');
            grunt.loadNpmTasks('grunt-contrib-uglify');

            // 4. Where we tell Grunt what to do when we type 'grunt' into the terminal.
            grunt.registerTask('default', ['concat, uglify']);

        };

的package.json:

{
  "name": "grunt_libsass_example-project",
  "version": "0.1.0",
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-contrib-concat": "^0.5.1",
    "grunt-contrib-uglify": "^0.9.1"
  }
}

1 个答案:

答案 0 :(得分:4)

您只传入registerTask任务列表的一个字符串。它应该是逗号分隔的字符串列表,如:

grunt.registerTask('default', ['concat', 'uglify']);

您收到该错误是因为它正在寻找名为' concat,uglify'的任务。