新的咕哝警告:任务;concat,uglify“;找不到

new to grunt - warning: task "concat, uglify" not found

本文关键字:concat 找不到 uglify 任务 警告      更新时间:2023-09-26

正如标题所说,我是Grunt的新手。我正在学习位于以下位置的教程:http://24ways.org/2013/grunt-is-not-weird-and-hard/.这是一个较老的教程,但大多数似乎都是一样的。我安装了"grunt contrib concat"answers"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"
  }
}

您只为registerTask任务列表传入一个字符串。它应该是一个包含字符串列表的数组,如:

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

你得到这个错误是因为它正在寻找一个名为"concat,uglify"的任务。

我必须运行:

npm install grunt-contrib-uglify --save-dev