4
votes

I'm trying to setup Sublime build process to run Grunt (v0.4) This is my build snippet:

{
    "cmd": ["grunt", "--no-color"],
    "selector": ["Gruntfile.js"],
    "path": "/usr/local/bin",
    "working_dir": "${project_path}",
    "osx": {
        "cmd": ["grunt", "--no-color"]
    }
}

When I hit Command-B I get the following error:

grunt-cli: The grunt command line interface. (v0.1.6) Fatal error: Unable to find local grunt.

If you're seeing this message, either a Gruntfile wasn't found or grunt hasn't been installed locally to your project. For more information about installing and configuring grunt, please see the Getting Started guide:

http://gruntjs.com/getting-started [Finished in 0.2s with exit code 99]

When I run grunt from the terminal everything is working.

Any ideas?

3

3 Answers

4
votes

It's a "bug" of Sublime Text. When you hit Ctrl+B, it will call the build command with the first open folder as the working directory. So if you haven't opened the folder, it cannot find the build file (Makefile, or in your case Gruntfile).

So in order to build successfully, you need to put your Gruntfile in the folder as the working directory, and then open the folder in Sublime Text and hit Ctrl+B.

0
votes

Before running GruntJS, you need to install it with: npm install grunt --save-dev In the new version of GruntJS, 'grunt' is not installed globally, so in every project you can use different versions of GruntJS.

0
votes

Enter which grunt from the command line, then put the full path in the "cmd" section - for example, "cmd": ["/opt/local/bin/grunt", "--no-color"]. The $PATH for ST2 can be different from the one in your CLI environment.