1$nid = 1;
2$entity_type = 'node';
3$view_mode = 'teaser';
4
5$view_builder = \Drupal::entityTypeManager()->getViewBuilder($entity_type);
6$storage = \Drupal::entityTypeManager()->getStorage($entity_type);
7$node = $storage->load($nid);
8$build = $view_builder->view($node, $view_mode);