The command grunt.cmd exited with code 6
I hate when I get obfuscated error message like 'The command "grunt.cmd" exited with code 6'. What the heck is code 6? Duh I know grunt did not work. Fortunately I figured this one out.
When you are running a grunt task or tasks and see this error echoed in the console it means you have a syntax error in the code. Typically you have a typo. The problem now is how to figure out where the typo is hiding.
var myObj = {
property1: 1,
property2: 2,
};
The first thing I look for is dangling commas. This is a common mistake because Grunt uses a JSON configuration object. Grunt may be an overlay to run different node modules, but it is driven by a big JSON object, which separates properties by commas. Because we tend to copy and paste code it is not uncommon to leave a trailing comma after the last property in the list. Remember it is not just the last task definition, but also look at the properties within each task configuration.
var myObj = {
property1 = 1,
property2: 2,
};
The next step is to make sure there are no missing semi-colons, again because we copy and paste. You could have copied an = from some JavaScript snippet.
var myObj = {
property1: 1,
property2: function(){
};
Next, make sure your brackets and semi-colons are in order. Again, copy, pasting and deleting does not always leave your code clean. It often creates a butchered ensemble that fails the script parsing process.
Finally copy your entire configuration object in an online JSON editor like JSON Editor Online. I like this editor because it allows me to clean format the code as well as attempt to point out the syntax exception visually so I can clean it up.
I would say run JSHint, but you would most likely want to run it using Grunt and well your configuration is already messed up and Grunt is not going to run anyway. So don't feel confused the next time you see exited with code 6 as your Grunt error message. Know your configuration object is just a little dinged up and needs a little love. Find your syntax typos and run again. Hopefully you will exit with a smile on your face.