When run grunt I get SyntaxError: Unexpected token (

When run grunt I get SyntaxError: Unexpected token (

如标题所述,当我 运行 G运行t 时会发生这种情况,我无法弄清楚我的代码有什么问题。我用JShint检查了一下,没有报错。

function () {
   'use strict';
}

module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        concat: {
            options: {
                separator: 'rn'
            },
            dist: {
                src: ['development/js/**/*js'],
                dest: 'development/js/compiled.js'
            }
        },

        uglify: {
            options: {
                banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */n'
            },
            dist: {
                files: {
                    'dist/js/main.min.js': ['<%= concat.dist.dest %>']
                }
            }
        },

        jshint: {
            files: ['development/js/**/*js'],
            options: {
                globals: {
                    jQuery: true,
                    console: true,
                    module: true
                }
            }
        },

        compass: {
            dist: {
                options: {
                    sassDir: 'development/css',
                    cssDir: 'dist/css',
                    environment: 'production',
                    outputStyle: 'compressed'
                }
            }
        },

        copy: {
            files: [
                {
                    cwd: 'development',  // set working folder / root to copy
                    src: '**/*html',           // copy all files and subfolders
                    dest: 'dist',    // destination folder
                    expand: true           // required when using cwd
                },
                {
                    cwd: 'development',  // set working folder / root to copy
                    src: 'img/*',           // copy all files and subfolders
                    dest: 'dist',    // destination folder
                    expand: true           // required when using cwd
                },
                {
                    cwd: 'development',  // set working folder / root to copy
                    src: 'fonts/*',           // copy all files and subfolders
                    dest: 'dist',    // destination folder
                    expand: true           // required when using cwd
                },
                {
                    cwd: 'path/to/files',  // set working folder / root to copy
                    src: '**/*',           // copy all files and subfolders
                    dest: 'dist',    // destination folder
                    expand: true           // required when using cwd
                }
            ]
        },

        watch: {
            files: ['<%= jshint.files %>', 'development/css/**/*.scss', 'development/**/*html'],
            tasks: ['concat', 'uglify', 'jshint', 'compass']
        }

    });

    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-compass');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-watch');

    grunt.registerTask('default', [
        'concat', 
        'uglify', 
        'jshint', 
        'compass',
        'copy'
    ]);
};

控制台输出:

Loading "Gruntfile.js" tasks...ERROR

SyntaxError: Unexpected token ( Warning: Task "default" not found. Use --force to continue.

由于警告而中止。

第一个函数有语法错误,尝试将第一个函数更改为:

(function(){
  "use strict";

 // Define your library strictly...
})();