加载“gruntfile.js”任务... ERROR>> TypeError:grunt.initconfig不是函数

时间:2018-03-01 18:35:26

标签: uglifyjs grunt-contrib-uglify

我无法找到错误的地方

gruntfile.js

module.exports = function(grunt){
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.initconfig({
    pkg: grunt.file.readJSON('package.json'),

    uglify:{
        t1:{
            files:{
                'dest/success.min.js' : ['js/one.js' ,'js/two.js'] 
            }

        }
    }
});

}; 

这是正在运行的错误 - grunt uglify:t1

Loading "gruntfile.js" tasks...ERROR
>> TypeError: grunt.initconfig is not a function

Running "uglify:t1" (uglify) task
Verifying property uglify.t1 exists in config...ERROR
>> Unable to process task.
Warning: Required config property "uglify.t1" missing. Use --force to 
continue.

Aborted due to warnings.  

1 个答案:

答案 0 :(得分:0)

Javascript区分大小写,因此initconfig不存在,请尝试initConfig

module.exports = function(grunt){
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    uglify:{
       t1:{
            files:{
               'dest/success.min.js' : ['js/one.js' ,'js/two.js'] 
            }

        }
    }
});

};