我在终端上遇到麻烦

时间:2018-01-10 02:58:21

标签: macos terminal gruntjs

我无法让我的终端正确运行grunt。我正在尝试创建一个新的grunt文件,我已经安装了grunt。而且我不知道为什么它会给我这个错误。

Last login: Tue Jan  9 19:42:51 on ttys000
Nicks-MacBook-Pro:~ nickcameron$ cd projects
Nicks-MacBook-Pro:projects nickcameron$ cd kittenbook
Nicks-MacBook-Pro:kittenbook nickcameron$ grunt
Loading "Gruntfile.js" tasks...ERROR
>> SyntaxError: Unexpected identifier
Warning: Task "default" not found. Use --force to continue.
Aborted due to warnings.
Nicks-MacBook-Pro: kittenbook nickcameron$

这是我的Gruntfile.js:

module.export = function (grunt){
    //project configuartion 
    grunt.initConfig({

        concat: {
            release: {
                src: ['js/values.js', 'js/prompt.js'],
                dest: 'release/main.js'
            }
        },
        copy: {
            release: {
                src: 'manifest.json',
                dest: 'release/manifest.json'
            }
        }
        jshint: {
            files: ['js/values.js', 'js/prompt.js']
        }
    /*
     * We will configure our tasks here
     */
    });
    // We will load Grunt plugins here
    //Load Grunt plugins
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-jshint'); 
    // We will register tasks here
    //Register tasks 
    grunt.registerTask ('default', ['jshint', 'concat', 'copy']);
}; 

1 个答案:

答案 0 :(得分:0)

module.export写错了,正确的是module.exports,你也忘记了逗号。您的gruntfiles.js应如下所示:

module.exports = function (grunt){
    //project configuartion 
    grunt.initConfig({

        concat: {
            release: {
                src: ['js/values.js', 'js/prompt.js'],
                dest: 'release/main.js'
            }
        },
        copy: {
            release: {
                src: 'manifest.json',
                dest: 'release/manifest.json'
            }
        }, // <----------------- missing comma here
        jshint: {
            files: ['js/values.js', 'js/prompt.js']
        }
    /*
     * We will configure our tasks here
     */
    });
    // We will load Grunt plugins here
    //Load Grunt plugins
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-jshint'); 
    // We will register tasks here
    //Register tasks 
    grunt.registerTask ('default', ['jshint', 'concat', 'copy']);
};