Using travis-ci with grunt 0.4.x

Update: 26/03/2013 Tim in the comments points out that if you add grunt-cli to your dev-dependencies in your package.json that will also achieve the same solution. I’d recommend his solution here instead of the below.

I thought I’d post a quick set of tips on how to setup on a grunt plugin project as I’d spent a while trying to find the answer.

My problem was that when I followed the travis guide to setup a node.js project all it told me I needed in my .travis.yml was:

language: node_js
  - "0.8"

However I kept getting failing builds which said:

> grunt test

sh: 1: grunt: not found
npm ERR! Test failed.  See above for more details.
npm ERR! not ok code 0

After a bit of digging around in some other projects it turns out you need one extra thing for a Grunt 0.4.x project to work:

language: node_js
  - "0.8"
  - npm install -g grunt-cli

After adding that travis was able to find grunt and I was back to green.

Feel free to look at for a working build setup.


5 Responses to “Using travis-ci with grunt 0.4.x”

  1. Daniel Steigerwald February 15, 2013 at 9:02 pm #

    Maybe would be better to run grunt-cli locally –
    “test”: “node ./node_modules/.bin/grunt test”,

  2. Matt Goldspink February 17, 2013 at 4:09 pm #

    @Daniel – that’s true. I basically copied what I found the grunt project doing and so assumed that’s the right way, but you make a good point. If I do it your way then I don’t need to install it globally. However I assume (perhaps wrongly) that travisci would clean up any global installations of modules people make and ensure everything is sandboxed for all jobs.

  3. Daniel Steigerwald February 21, 2013 at 12:38 pm #

    Yes it cleans up, see

  4. Tim Branyen February 25, 2013 at 3:01 pm #

    It’s even easier than that. You can just install it as a devDependency and it will automatically get sourced to your path.

  5. astrism March 25, 2013 at 9:37 pm #

    @Tim, Thanks that is definitely the way to go!

Leave a Reply

%d bloggers like this: