Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gruntjs grunt.js文件中出现意外标识符错误_Gruntjs - Fatal编程技术网

Gruntjs grunt.js文件中出现意外标识符错误

Gruntjs grunt.js文件中出现意外标识符错误,gruntjs,Gruntjs,有人能告诉我为什么在运行以下grunt.js文件时在终端中出现以下错误吗 module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), concat: { // Here is where we do our concatenating dist: { src: [ 'components/js/*.js' /

有人能告诉我为什么在运行以下grunt.js文件时在终端中出现以下错误吗

module.exports = function(grunt) {

grunt.initConfig({

    pkg: grunt.file.readJSON('package.json'),

    concat: { // Here is where we do our concatenating
      dist: {
      src: [
      'components/js/*.js' // everything in the src js folder
    ],
    dest: 'js/script.js',
    }
    }

    uglify: {
    build: {
    src: 'js/script.js',
    dest: 'js/script.min.js'
    }
    }

});

//Add all the plugins here
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');

//What happens when we type 'grunt' in the terminal
grunt.registerTask('default', ['concat', 'uglify']);

};
我得到的错误是:

Loading "gruntfile.js" tasks...ERROR
SyntaxError:意外的标识符 警告:未找到任务“默认值”。使用--force继续

谢谢

您缺少一个逗号:
grunt.initConfig({
pkg:grunt.file.readJSON('package.json'),
康卡特:{
地区:{
src:[
'components/js/*.js'
],
dest:'js/script.js',
}

},//尽管其他内容都是正确的,但我还是被丢失的逗号绊倒了,谢谢你指出,它甚至在同一个位置。这个问题太具体了。我有完全相同的错误消息,但却是一个完全不同的gruntfile.js(它也大得多)。当前公认的答案是针对该问题的,对于解决类似问题不是很有用。更好的问题是“如何在Grunfile.js中找到导致语法错误的原因?”这一问题在回答时对更多人有用。
module.exports = (grunt) ->
  grunt.initConfig

    pkg: grunt.file.readJSON("package.json")

    concat:
      dist:
        src: ["components/js/*.js"]
        dest: "js/script.js"

    uglify:
      build:
        src: "js/script.js"
        dest: "js/script.min.js"


  grunt.loadNpmTasks "grunt-contrib-concat"
  grunt.loadNpmTasks "grunt-contrib-uglify"

  grunt.registerTask "default", [
    "concat"
    "uglify"
  ]