unexpected identifier error in grunt.js file

gruntjs

Solution

You have a missing comma:

grunt.initConfig({

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

  concat: {
    dist: {
      src: [
        'components/js/*.js'
      ],
      dest: 'js/script.js',
    }
  }, // <---- here was a missing comma

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

Make yourself a favor and use coffeescript!

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"
  ]

Problem

Can anyone tell me why I am getting the following error in terminal when running the following grunt.js file? ``` 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']); }; ``` The error I get is: ``` Loading "gruntfile.js" tasks...ERROR ``` SyntaxError: Unexpected identifier Warning: Task "default" not found. Use --force to continue. THANKS!

Original source