Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools

Adam Menczykowski
Adam Menczykowski
2,319 Points

Any grunt command that I input into the terminal results in -bash: grunt-init: command not found

I am on OS X 10.9.5 Node v0.10.32 npm 2.0.2

after running the following, i get: npm install -g grunt-cli

/Users/adammenczykowski/.node/bin/grunt -> /Users/adammenczykowski/.node/lib/node_modules/grunt-cli/bin/grunt
grunt-cli@0.1.13 /Users/adammenczykowski/.node/lib/node_modules/grunt-cli
├── resolve@0.3.1
├── nopt@1.0.10 (abbrev@1.0.5)
└── findup-sync@0.1.3 (lodash@2.4.1, glob@3.2.11)

contents of .bash_profile is:

export PATH=/Users/adammenczykowski/.node/lib/node_modules/grunt-cli:$PATH

The content of my gruntfile.js is:

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    uglify: {
      options: {
        banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
      },
      build: {
        src: 'css/main.css',
        dest: 'css/main.min.css'
      }
    },

    sass: {                              // Task
        dist: {                            // Target
          options: {                       // Target options
            style: 'nested'
          },
          files: {                         // Dictionary of files
            'css/main.css': 'css/main.scss',       // 'destination': 'source'
          }
        }
  }

  });


  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-contrib-uglify');

  // Default task(s).
  grunt.registerTask('default', ['sass', 'uglify']);

};

and package.json:

{
  "name": "site.adam.menczykowski.co.uk",
  "version": "1.0.0",
  "description": "Writing content for my site",
  "main": "index.jsd",
  "directories": {
    "doc": "doc"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/admench/site.adam.menczykowski.co.uk.git"
  },
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/admench/site.adam.menczykowski.co.uk/issues"
  },
  "homepage": "https://github.com/admench/site.adam.menczykowski.co.uk",
  "devDependencies": {
    "grunt": "^0.4.5",
    "grunt-contrib-sass": "^0.8.1",
    "grunt-contrib-uglify": "^0.6.0"
  }
}

Can anybody offer any assistance in getting grunt up and running?

5 Answers

Aaron Graham
Aaron Graham
18,033 Points

-bash: grunt: command not found actually makes more sense than -bash: grunt-init: command not found. You might try adding /bin to the end of your $PATH export in .bash_profile:

export PATH=/Users/adammenczykowski/.node/lib/node_modules/grunt-cli/bin:$PATH

Does that work?

Edit: you might need to close and reopen your terminal window to get it to reprocess .bash_profile

Aaron Graham
Aaron Graham
18,033 Points

How are you running your tasks? Have you tried running them individually (e.g. grunt sass, or grunt uglify) to see if it is any one particular task that is failing? You could just try and npm install -g grunt-init and see if that fixes your problem.

Adam Menczykowski
Adam Menczykowski
2,319 Points

Thanks Aaron,

Running

grunt sass

//or 

grunt uglify

Yields the same frustrating response: -bash: grunt: command not found

Even after installing grunt-init globally I get the same response.

Thanks in advance for any extra help.

Adam

Adam Menczykowski
Adam Menczykowski
2,319 Points

Thanks so much Aaron, I am now up and running with Grunt thanks to you :-)

Aaron Graham
Aaron Graham
18,033 Points

Glad I could help! Enjoy Grunt...

Adam Menczykowski
Adam Menczykowski
2,319 Points

I did not include the /bin part of the URL, so bash could not run grunt from anywhere until that was altered.