2013-11-27 7 views
18

Jestem nowy w NodeJS i Grunt i staram się, aby to działało. Oto co mam:Grunt nie uruchamia się: ">> ReferenceError: grunt nie jest zdefiniowany"

$> grunt 
Loading "Gruntfile.js" tasks...ERROR 
>> ReferenceError: grunt is not defined 
Warning: Task "default" not found. Use --force to continue. 

Aborted due to warnings. 

Oto mój Gruntfile:

module.exports = function(grunt) { 
     grunt.initConfig({ 
       compass: { 
         dist: { 
           options: { 
             config: 'config/config.rb' 
           } 
         } 
       } 
     }); 
}; 

grunt.loadNpmTasks('grunt-contrib-compass'); 

grunt.registerTask('default', 'compass'); 

A oto moja package.json:

{ 
    "name": "tests", 
    "version": "0.0.0", 
    "description": "Grunt Tests", 
    "main": "index.js", 
    "devDependencies": { 
    "grunt": "~0.4.2", 
    "grunt-contrib-compass": "~0.6.0", 
    "grunt-contrib-watch": "~0.5.3", 
    "grunt-cli": "~0.1.11" 
    }, 
    "scripts": { 
    "test": "grunt compass" 
    }, 
    "repository": { 
    "type": "git", 
    "url": "https://github.com/Bertrand31/grunttests.git" 
    }, 
    "keywords": [ 
    "Grunt", 
    "NodeJS", 
    "NPM", 
    "SASS", 
    "Compass" 
    ], 
    "author": "Bertrand Junqua", 
    "license": "GPL", 
    "bugs": { 
    "url": "https://github.com/Bertrand31/grunttests/issues" 
    }, 
    "homepage": "https://github.com/Bertrand31/grunttests" 
} 

No i biegnę to na Debian sid.

Jeśli masz jakiś pomysł, daj mi znać. Wielkie dzięki!

+0

Czy uruchamiasz polecenie z tego samego katalogu, co plik Gruntfile? –

+0

Też nie sądzę, że to robi różnicę. Ale myślę, że twoje zadania rejestru powinny wyglądać następująco: 'grunt.registerTask ('default', ['compass']);'. –

Odpowiedz

38

Dzwonisz pod numer grunt.loadNpmTasks i grunt.registerTask z zakresu, w którym grunt nie jest zdefiniowany. Będziesz musiał do nich zadzwonić w funkcji module.exports:

module.exports = function(grunt) { 
    grunt.initConfig({ 
      compass: { 
        dist: { 
          options: { 
            config: 'config/config.rb' 
          } 
        } 
      } 
    }); 

    // Call these here instead, where the variable grunt is defined. 
    grunt.loadNpmTasks('grunt-contrib-compass'); 

    grunt.registerTask('default', 'compass'); 
}; 
+0

To działa! Dziękuję bardzo! :) – Bertrand

Powiązane problemy