You can sometimes run in to trouble if you have a Gruntfile.js in a theme's folder if you want to compile an AMD module within that theme.
We had to modify our theme's Gruntfile.js and package.json to make it include the core grunt tasks in our Gruntfile.js
Modification to package.json:
"grunt-load-gruntfile" : "^0.0.2" <- added to "devDependencies"
Modification to the themes Gruntfile.js module exports
module.exports = function(grunt) {
// We need to include the core Moodle grunt file too, otherwise we can't run tasks like "amd".
require("grunt-load-gruntfile")(grunt);
grunt.loadGruntfile("../../Gruntfile.js");
Modification to the themes Gruntfile.js grunt.initConfig (note grunt.initConfig is swapped for grunt.mergeConfig)
grunt.mergeConfig = grunt.config.merge;
grunt.mergeConfig({