sitecore Habitat - TypeError: Cannot read property '0' of undefined
When you get the error TypeError: Cannot read property '0' of undefined in the Gulp task '05-Sync-Unicorn' you probably don't have a SharedSecret configured in the file C:\Projects\Habitat\src\Project\Habitat\code\App_Config\Include\Unicorn\Unicorn.UI.config.
In my project the SharedSecret wat commented out, i.e.:
<!--<SharedSecret></SharedSecret> Uncomment this line and provide a strong randomized shared secret here. At least 64 characters is recommended, for example https://www.grc.com/passwords.htm -->
I followed the instructions, uncommented it, grabbed a 64 characters password from https://www.grc.com/passwords.htm so my line read:
<SharedSecret>06A3203AA36C84D499D9BF6F79852B61EF2992465C2160FE09263E1AB5B882E2</SharedSecret>
I did run gulp 05-Sync-Unicorn
again, but still the same error.
After adding a line to the script C:\Projects\Habitat\scripts\unicorn.js:
console.log("Reading Unicorn configuration file " + unicornConfigFile);
var data = fs.readFileSync(unicornConfigFile);
gulp default
task again, but doing a Publish... on the Sitecore.Habitat.Website project (right-click on the project) does the job much quicker.secret = result.configuration.sitecore[0].unicorn[0].authenticationProvider[0].SharedSecret[0];