How do I print the term names associated with a node?
You can do this:

foreach($nodes as $node) {
  $categories = $node-&gt;field_category-&gt;referencedEntities();
  foreach($categories as $category) {
    print_r($category-&gt;getName(). ",");
  }
  print("\n");
}