yedincifirat
yedincifirat

Reputation: 147

GruntJs Tasks issues

GruntJS file give me an error, enter image description here

and my package.json

{
  "name": "todolist",
  "version": "0.0.0",
  "description": "todolist uygulamasi",
  "main": "index.html",
  "author": "Yedinci",
  "scripts": {
    "build": "browserify js/main.js -o js/output.js",
  },
  "license": "ISC",
  "devDependencies": {
    "browserify": "^13.0.0",
    "grunt": "^0.4.5",
    "grunt-contrib-compass": "^1.0.4",
    "grunt-contrib-cssmin": "^0.14.0",
    "grunt-contrib-sass": "^0.9.2",
    "grunt-contrib-uglify": "^0.11.0",
    "grunt-contrib-watch": "^0.6.1",
    "jquery": "^2.2.0",
  }
}

and I couldn't solve.How to solve this issues ? what does unexpected token ?

Upvotes: 1

Views: 37

Answers (2)

Henry Zou
Henry Zou

Reputation: 1917

could be caused by the trailing commas. Try this:

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

    watch: {
      js: {
        files: ['js/**/*.js'],
        tasks: ['uglify']
      }
    },

    compass: {
      dev: {
        options: {
          sassDir: ['sass/scss'],
          cssDir: ['css/css'],
          environment: 'development'
        }
      }
    },

    cssmin:{
      combine:{
        files:{
          'css/output.css':['css/screen.css','css/print.css']
        }
      }
    },

    sass: {
      dist: {
        options: {
          style: 'compressed'
        },
        files: {
          'css/output.css': 'sass/main.scss'
        }
      }
    },

    // uglify..
    uglify:{
      dist:{
        files:{
          'js/output.js':['node_modules/jquery/dist/jquery.js','node_modules/bootstrap/bootstrap.js','js/main.js']
        }
      }
    }
  });

  //load plugin
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-watch');
  // do the task
  grunt.registerTask('default',['cssmin','sass','uglify']);
};

in your gruntfile.js, you are missing a task named "watch". Just because you installed the npm package, doesn't automatically create grunt tasks for you.

Upvotes: 0

Fraser Crosbie
Fraser Crosbie

Reputation: 1762

Remove the commas at the end of:

"build": "browserify js/main.js -o js/output.js",

and

"jquery": "^2.2.0",

as they are the last name/values pairs defined in the object.

Upvotes: 2

Related Questions