gpt4 book ai didi

javascript - 运行 grunt 时出现 SyntaxError : Unexpected token (

转载 作者:行者123 更新时间:2023-11-29 10:37:39 25 4
gpt4 key购买 nike

如标题所述,当我运行 Grunt 时会发生这种情况,但我无法弄清楚我的代码有什么问题。我用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...
})();

关于javascript - 运行 grunt 时出现 SyntaxError : Unexpected token (,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34253905/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com