Grunt没有给出任何输出[Ubuntu]

时间:2013-11-13 11:58:39

标签: gruntjs

我的咕噜声没有给出任何输出,我刚刚安装了所有系统,NPM和grunt-cli。当我输入“grunt -v”时,不会返回任何内容。 这是我的package.json:

{
  "name": "project",
  "version": "2.0.0",
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-contrib-coffee": "~0.7.0",
    "grunt-contrib-compass": "~0.6.0",
    "grunt-contrib-uglify": "~0.2.2",
    "grunt-contrib-watch": "~0.5.3",
    "grunt-yui-compressor": "~0.3.0",
    "grunt-contrib-cssmin": "~0.7.0"
  }
}

我的Gruntfile.coffee是:

module.exports = (grunt) ->

  # Project configuration.
  grunt.initConfig
    pkg: grunt.file.readJSON("package.json")

    coffee:
      glob_to_multiple:
        expand: true
        flatten: true
        src: ['assets/javascripts/source/*.coffee']
        dest: 'assets/javascripts/build/'
        ext: '.js'

    compass:
      dev:
        options:
          config: 'config.rb'

    cssmin:
      add_banner:
        options:
          banner: '/* Compilado em ' + grunt.template.today('dd/mm/yyyy') + ' */'
        files:
          'assets/styles/build/site.min.css': ['assets/styles/build/site.css']
          'assets/styles/build/site-ie7.min.css': ['assets/styles/build/site-ie7.css']

    uglify:
      dev:
        files:
          'assets/javascripts/build/scripts.min.js':[
            'assets/javascripts/build/scripts.js'
            'assets/javascripts/build/zt-validator.js'
            'assets/javascripts/build/jquery-zt.js'
          ]
      dist:
        files:
          'assets/javascripts/build/scripts-full.min.js':[
            'assets/javascripts/build/scripts.js'
            'assets/javascripts/build/zt-validator.js'
            'assets/javascripts/build/jquery-zt.js'
            'assets/javascripts/build/site.js'
          ]

    watch:
      options: { spawn: false }
      coffee:
        files: ["assets/javascripts/source/*.coffee"]
        tasks: ["coffee","uglify"]
      compass:
        files: ["assets/styles/**/*.sass","assets/styles/**/*.scss"]
        tasks: ["compass","cssmin"]


  grunt.loadNpmTasks "grunt-contrib-coffee"
  grunt.loadNpmTasks "grunt-contrib-watch"
  grunt.loadNpmTasks "grunt-contrib-compass"
  grunt.loadNpmTasks "grunt-contrib-cssmin"
  grunt.loadNpmTasks "grunt-contrib-uglify"

  # Default task(s).
  grunt.registerTask "default", ["coffee", "compass"]

我不知道如何调试它。

3 个答案:

答案 0 :(得分:37)

尝试删除包“node”。它与NodeJS无关,删除它解决了我的问题。

您可以运行sudo apt-get remove node并使用nodejs-legacy

重新安装sudo apt-get install nodejs-legacy来完成此操作

答案 1 :(得分:8)

我必须在Ubuntu 13.10上安装'node-legacy'才能让'grunt'正常工作。仅仅安装'node'是不够的。

答案 2 :(得分:1)

如果您没有使用grunt-cli的最新版本,请升级它。

您可能会遇到已解决的问题this update,这可能会解释您和我使用交换机时获得的不同结果。